population_sacha/class_RLE_Image.cpp
// Combine overvlapping or inlaid runs with the coordinate j

Combine overvlapping or inlaid runs with the coordinate j
Combine overvlapping or inlaid runs with the coordinate j
void RLE_Image::combine_runs()
{
	pop::Mat2UI8 image=output();
	RLE_Image temp_RLE_image (image);
	swap(*this, temp_RLE_image);
}
void RLE_Image :: combine_runs ( ) { pop :: Mat2UI8 image = output ( ) ; RLE_Image temp_RLE_image ( image ) ; swap ( * this , temp_RLE_image ) ; }
Combine overvlapping or inlaid runs with the coordinate j
Combine overvlapping or inlaid runs with the coordinate j
/*
	// Local variables
	bool last_on;
	bool *temp_row;
	int i;
	int j;
	int k;
	int i_run_start;
	int i_run_end;
	*/ // Converting runs to an image, which eliminates redundant runs
 // Converting the image back to runs
 // Replacing the old class instance with the new one
 /*
	
	// Initialize an empty image of the necessary size
	
	
	// Initialize with zeros a pixel row to which all runs will be projected 
	//temp_row = new bool [size_i];		

	// Parsing all the runs looking for j0 and plotting them on the row
	for (k=runs_number-1; k>=0; k--)
	{
		if (image_runs[k]->j==j0)
		{
			// Projecting this run
			for (i=image_runs[k]->iLeft; i<=image_runs[k]->iRight; i++)
				temp_row[i]=1;
			
			// Deleting the run with j0
			deleteRun(k);
		}
	}

	// Saving the obtained row as runs
	last_on=false;
	for (i=0; i<size_i; i++)
	{
		if (last_on==false)		// If the previous pixel was off
		{
			if (temp_row[i])		// If the current pixel is on, marking the starting position of a new run
			{
				i_run_start=i;
				last_on=true;
			}
		}
		else    // If the previous pixel was on
		{
			if (temp_row[i]==false)		// If the current pixel is off, saving the run
			{
				i_run_end=i-1;
				addNewRun(i_run_start, i_run_end, j0);
				last_on=false;
			}
		}

	}
	if (last_on) // If the row ended, but the last pixel was on, save a new run
	{
		i_run_end=size_i-1;
		addNewRun(i_run_start, i_run_end, j0);
		last_on=false;
	}

	*/