image processing - How do I create a histogram which can be used for calcBackProject in opencv? -


i have specified histogram as

matnd skincrcbhist =mat::zeros(size(256,256),cv_8uc1);  ellipse(skincrcbhist, point(113, 155.6), size(283.4, 159.2), 43.0, 0.0, 360.0, scalar(255), -1); // using big ellipse find sort of projection in crcb domain.  cvtcolor(src, ycrcb, cv_bgr2ycrcb); //src input, image of person float crrange[]={0,255}; float cbrange[]={0,255}; const float* ranges[]={crrange,cbrange}; int channelsy[]={1,2}; calcbackproject( &ycrcb, 1, channelsy, skincrcbhist, backproj, ranges, 255, true ); imshow("bp",backproj); 

the problem face backproj shows black image. when used normal histogram created calchist on natural image, sort of backprojection. how use histogram, create artificially, specifying ellipse, backprojection.

if understood problem correctly, use mask original calchist function.

you didn't specified version of opencv using, assume latest 2.4.6.0. method prototype following (omitting defaults, , types):

calchist(images, nimages, channels, mask, hist, dims, histsize, ranges)

the third parameter mask. mask means, function ignore pixels matches 0 pixels in mask. in program mask image correctly setup.

here pseudo-code problem:

1) input image 2) create matrix of same size input of type cv_8uc1 filled zeros 3) draw white (value 255) ellipse on new image 4) call caclhist new image mask 

http://docs.opencv.org/modules/imgproc/doc/histograms.html


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -