c++ - how to change Width Scale in Opencv Histogram.(640 X 480) -
how change width scale in opencv histogram.
my code result express width 0 ~ 255, want change width 640 use scale. , want find mistakes on code, , suggest me solution..
please me.
void mainwindow::basic_histogram(iplimage* timage) { iplimage* canvas; int hist[256]; double scale=1; int i,j,max=0; qimage pimage; canvas = cvcreateimage(cvsize(640, 480), ipl_depth_8u, 3); cvset(canvas,cv_rgb(255,255,255),0); for(i=0;i<256;i++) { hist[i]=0; } for(i=0;i<timage->height;i++) { for(j=0;j<timage->width;j++) { hist[(uchar)timage->imagedata[(i * timage->widthstep) + j]]++; } } max = 256 * 10; (i = 0; < 256; i++) { max = hist[i] > max ? hist[i] : max; } scale = max > canvas->height ? (double)canvas->height/max : 1.; (i = 0; < 256; i++) { cvpoint pt1 = cvpoint(i, canvas->height - (hist[i] * scale)); cvpoint pt2 = cvpoint(i, canvas->height); cvline(canvas, pt1, pt2, cv_rgb(0,0,0), 1, 8, 0); } pimage = iplimage2qimage(canvas); emit newedgeframe(pimage); cvreleaseimage(&canvas); }
below picture show code result.
Comments
Post a Comment