Exemple #1
0
/**
 * Replace vector null values by average (better for histogram display) 
 * @param v vector to modify
 */
void OverlayData::correctVector( HistogramVector& v ) const
{
	for(unsigned int i=1; i<v.size()-1;++i)
	{
		if(v.at(i) < 0.05)
			v.at(i) = (Number)((v.at(i-1)+v.at(i+1))/2.0);//basic average
	}
}
/**
 * display selection points under the histograms
 * @param selection_v buffer which contains all of the selection points
 * @param step step for display
 * @param width width of the source clip
 * @param color color using for display
 */
void displaySelectionPoints(const HistogramVector& selection_v, const double step, const double width, const HistogramColor color)
{
	glBegin( GL_POINTS );
	double base_step = 0.0;
	glColor3f(color._colorBorder.r, color._colorBorder.g, color._colorBorder.b);
	for(unsigned int i=0; i<selection_v.size(); ++i)
	{
		if(selection_v.at(i) != 0)
		{
			glVertex2f((float)(base_step), -10.0f);
		}	
		base_step += step;
	}
	glEnd();
}
Exemple #3
0
/**
 * Compute a specific channel average
 * @param selection_v vector which contain the selection histogram
 * @return 
 */
int OverlayData::computeAnAverage( const HistogramVector& selection_v ) const
{
	int av = 0;
	int size = 0;
	for( std::size_t i=0; i < selection_v.size(); ++i)
	{
		if(selection_v.at(i)!=0)
		{
			av+=selection_v.at(i)*i;
			size+=selection_v.at(i);
		}
	}
	if(size != 0) //avoid 0 division
		av /=size;
	return av; //basic average
}
/**
 * Display the given vector on screen (only border)
 * @param v specific vector to display on overlay
 * @param step step of the display
 * @param height maximal height
 * @param width maximal width
 * @param color color used to display
 */
void displayASpecificHistogramBorder(const HistogramVector& v, const double step, const double height, const double width, const HistogramColor color)
{
	//Draw the border line
	glBegin( GL_LINE_STRIP );
	//maximum data in the current channel vector
	const Number max_value = *(std::max_element(v.begin(),v.end()));
	const float ratio = height/max_value;
	double base_step = 0.0;
	glColor3f(color._colorBorder.r, color._colorBorder.g, color._colorBorder.b);
	for(unsigned int i=0; i<v.size(); ++i)
	{
		const float value = (float)(v.at(i)*ratio);
		glVertex2f((float)(base_step), float(value));
		base_step += step;
	}
	glEnd();
}
/**
 * Display the given vector on screen
 * @param v specific vector to display on overlay
 * @param step step of the display
 * @param height maximal height
 * @param width maximal width
 * @param color color used to display
 */
void displayASpecificHistogram(const HistogramVector& v,const HistogramVector& selection_v, const double step, const double height, const double width, const HistogramColor color,float selectionMultiplier)
{
	if(v.size())
	{
		//maximum data in the current channel vector
		const Number max_value = *(std::max_element(v.begin(),v.end()));
		const float ratio = height/max_value;
		//OpenGL 2.X
		glEnable(GL_BLEND);
		glBlendFunc(GL_ONE, GL_ONE); //additive blending active
		glColor3f(color._colorFill.r, color._colorFill.g, color._colorFill.b);
		//Display option
		glBegin( GL_QUAD_STRIP );
		double base_step = 0.0;//first point
		for(unsigned int i=0; i<v.size(); ++i)
		{
			const float value = (float)(v.at(i)*ratio);
			float selection_value = (float)(selection_v.at(i)*ratio);
			selection_value*= selectionMultiplier;
			if(selection_value > value) //if selection value is bigger than normal value replace it
				selection_value = value;
			glVertex2f((float)(base_step), (float)(value));
			glVertex2f((float)(base_step), (float)(selection_value));
			base_step += step;
		}
		glVertex2f((float)width,0.0f);//last point
		glEnd();
		glDisable(GL_BLEND);
	}
}
Exemple #6
0
/**
 * @brief Set each values of the vector to null
 * @param v vector to reset
 * @param numberOfStep number of step (size of the vector)
 */
void OverlayData::resetVectortoZero( HistogramVector& v, const std::size_t numberOfStep ) const
{
	v.assign(numberOfStep,0);
}