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
Post a Comment