vector<byte> v_char; //values of pixels taken from y-axis //tried double and int as well.
//store pixel values into v_char
v_char.reserve(image.rows * image.cols);
for (int i = 0; i < image.rows; i++)
{
int segment_start = *(uchar*)image.data + i * image.step;
v_char.insert(v_char.end(), segment_start, segment_start + image.cols);
}
//plotting of v_char vector
plota->setTitle( "Plot Analysis" ); //Name the plot
plota->setCanvasBackground( Qt::black ); //Set the Background colour
plota
->setAxisScale
( QwtPlot::yLeft,
0,
1000000 );
//Scale the y-axis plota
->setAxisScale
(QwtPlot::xBottom,
0,image.
rows);
//Scale the x-axis plota
->insertLegend
(new QwtLegend());
//Insert a legend
//attach curve to plota
// curvea->setTitle("Count"); //Name the curve
curvea->setPen( Qt::white, 2);//Set colour and thickness for drawing the curve
//Use Antialiasing to improve plot render quality
curvea
->setRenderHint
( QwtPlotItem::RenderAntialiased,
true );
for( int h = 0; h < v_char.size(); ++h)
{
float bin_value = v_char[h];
points <<
QPointF((float)h, bin_value
);
}
curvea->setSamples(points); //pass points to be drawn on the curve
curvea->attach( plota ); // Attach curve to the plot
plota->resize( 600, 400 ); //Resize the plot
//plot.replot();
plota->show(); //Show plot
vector<byte> v_char; //values of pixels taken from y-axis //tried double and int as well.
//store pixel values into v_char
v_char.reserve(image.rows * image.cols);
for (int i = 0; i < image.rows; i++)
{
int segment_start = *(uchar*)image.data + i * image.step;
v_char.insert(v_char.end(), segment_start, segment_start + image.cols);
}
//plotting of v_char vector
QwtPlot *plota=new QwtPlot(); //Create plot widget
plota->setTitle( "Plot Analysis" ); //Name the plot
plota->setCanvasBackground( Qt::black ); //Set the Background colour
plota->setAxisScale( QwtPlot::yLeft, 0, 1000000 ); //Scale the y-axis
plota->setAxisScale(QwtPlot::xBottom,0,image.rows); //Scale the x-axis
plota->insertLegend(new QwtLegend()); //Insert a legend
//attach curve to plota
QwtPlotCurve *curvea = new QwtPlotCurve(); // Create a curve
// curvea->setTitle("Count"); //Name the curve
curvea->setPen( Qt::white, 2);//Set colour and thickness for drawing the curve
//Use Antialiasing to improve plot render quality
curvea->setRenderHint( QwtPlotItem::RenderAntialiased, true );
QPolygonF points;
for( int h = 0; h < v_char.size(); ++h)
{
float bin_value = v_char[h];
points << QPointF((float)h, bin_value);
}
curvea->setSamples(points); //pass points to be drawn on the curve
curvea->attach( plota ); // Attach curve to the plot
plota->resize( 600, 400 ); //Resize the plot
//plot.replot();
plota->show(); //Show plot
To copy to clipboard, switch view to plain text mode
Bookmarks