java - OpenCV: calcHist puts all results in the first bin -


i working on opencv 3.0 project in java, want detect percentage of yellow found in image. however, when calculate histogram of hue values, end histogram bins contain value 0.0 besides first bin. seems if contains observations.

here extract image - since work opencv, hue value should in following range 0-179:

        //establish number of bins         matofint histsize = new matofint(10);          //  set range value, upper bound exclusive         //  hue varies 0 179         matoffloat histrange = new matoffloat(0f, 180f);          //  histogram of hue value computed --> channel 0 == hue         matofint channel = new matofint(0);          mat histref= new mat();         arraylist<mat> histimages = new arraylist<mat>();         histimages.add(hsvroi);          //definition: calchist(images, channels, mask, hist, histsize, ranges, accumulate)         imgproc.calchist(histimages, channel, new mat(), histref, histsize, histrange);          core.normalize(histref, histref, 0, 1, core.norm_minmax, -1, new mat()); 

accessing bins:

for(int = 0; < 10; i++ ){             log.d(tag, "bin" + + " in hist: " + histref.get(i, 0)[0]);         } 

result log-cat (shortened):

bin0 in hist: 28994.0 bin1 in hist: 0.0 bin2 in hist: 0.0 .... , on pixels in mat 

any on issue appreciated, rachel


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -