Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Why doesn't the inRange() function detect this little red colored blob in this 50px Mat?

$
0
0
I created the following `50px by 50px` image in Adobe PS, and the red circle has an `HSV` value of `H=5, S=90, V=80`, where the `HSV` scale in PS is `H=0-360, S=0-100, V=0-100`. The `HSV` scale in OpenCV is `H=0-180, S=0-100, V=0-100`, so in OpenCV terms, the `HSV` value of the red circle in the image is `H= 5/2 =2.5`, `S= (90/100)*255 =229.5`, `V= (80/100)*255 =204`. The range I have given to the `inRange()` function in the following code snippet is `H=0-10, S=50-255, V=40-255`. I stored the in my sdcard by the name of `rgbaFrame.jpg`. [![enter image description here][1]][1] Please refer to the code below. `rgbaFrame` `Mat` converted to `HSV` `Mat` resulted in the following image named `hsvImage.jpg`. [![enter image description here][2]][2] But then when the `inRange` method was executed, the resulting `Mat` was `maskedImage.jpg`. (*So obvicously I got an **Exception** here)*: [![enter image description here][3]][3] public void doProcessing(View view) { Mat rgbaFrame = Highgui.imread("/mnt/sdcard/DCIM/rgbaFrame.jpg"); Mat hsvImage = new Mat(); Imgproc.cvtColor(rgbaFrame, hsvImage, Imgproc.COLOR_RGB2HSV); Highgui.imwrite("/mnt/sdcard/DCIM/hsvImage.jpg", hsvImage);// check Mat maskedImage = new Mat(); /**Color Tested: In PS: H=5, S=90, V=80 | In OpenCV: H=5/2=2.5, S=90/100*255=229.5, V=80/100*255=204 (OPENCV SCALE: h=0-180, s=0-255, v=0-255) */ Core.inRange(hsvImage, new Scalar(0, 50, 40), new Scalar(10, 255, 255), maskedImage); Highgui.imwrite("/mnt/sdcard/DCIM/maskedImage.jpg", maskedImage);// check } __________________________________________________ ***Note:** The code given is a part of an SSCCE I wrote. If you think I should post the complete SSCCE, please let me know.* [1]: http://i.stack.imgur.com/7kHrB.jpg [2]: http://i.stack.imgur.com/vmq7K.jpg [3]: http://i.stack.imgur.com/92Ogg.jpg

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>