Finding sum using mask in opencv [closed]
I want to sum only non zero pixel value, so is there any function in opencv to get that like the function mean(src, mask) as I used sumElmes() but it gives the sum of all values. Any suggestions or any way to solve that eve without builtin functions.
why so ? zero's never change the sum.
Yes, I new that but what if i want to log the pixel value. for example I have this equation:
It give me error for black pixels.
Do you try countNonZero() ???
and the error is ?
Yes I did Mat location = new Mat(); Core.findnonezero(src, location) but I confused with the location mat, Can I apply sumEmes() directly on it or it just a location and I need to match those locations with the src image?
Please help me.
you need to get the pixel value from the image, at that location (x,y).
but again, where's the error with the original approach ? (most probably you do not need any workarounds)
There is black pixels in the first approach which not valid using Core.log
hmm, i very much doubt so. 0 values are valid for log(). proof ? exact error ?
"I want to sum only non zero pixel value" <- if you sum also pixel with 0 value, the total would be exactly the same with or without them because they are zeros...
@berak sorry it was another mistake which makes my app stop. I get the entropy value but it seems a big number which mean it counts even zero values and I only want to count the entropy of none zero values.