How to calculate standard deviation on image with transparency
Hello everyone.
How do I calculate the standard deviation and mean on a certain image with transparency? I tried loading an image and then calculate the stddev and mean but I'm getting unexpected results.
This is my image with transparency:
Now, I want to calulate this only on the red star. So how do I do this? Because OpenCV treats transparent as black.
Thanks.
honestly, try to avoid images with transparency for computer-vision. those were made, to look nice in games or on webpages, but here, you have a problem. (even, if you read it in correctly, using the IMREAD_ANY_COLOR flag)
"I want to calulate this only on the red star." -- not possible. you will always have some border pixels around it
Thanks Berak! I will try to find another way then.
it's a bit unclear, what you're trying to achieve here. even if you could avoid the border pixels, using a mask or such, -- the stddev of a monochrome surface is just 0, right ? (remember your last experiment)
so, what is it about ?
well, i want to know the mean color of the object. This is just 1 color, but I have other images which have a lot of different colors in it. For example an image that contains a rose. I segmented the rose out of the image and so I have my blob ready. Now I need stddev and mean calculations which I can use for other things. Now I know that stddev of a monochrome surface is 0. That's why I don't use a mask.
maybe you can sample a small roi inside the star, like:
Yes, I was thinking the same thing. Maybe, because I can find the contour of the star and find the center of that contour and after that create a ROI around the center. I will try! Thanks for your help! :)