How can I detect if the backgroud is brighter than the coins or it's darker?
4 views (last 30 days)
Show older comments
For example:


It is important because when I make a binary image out of them, than I have to invert the image to be able to count it. (I have to invert the one with a brighter background) What is the best solution for this problem?
0 Comments
Answers (1)
Walter Roberson
on 28 Feb 2016
Examine the 4 corners. rgb2gray them, find out how many are > 128. If at least 3 are > 128 then you have a bright background.
This is not fool-proof. A solid bright red or bright blue background would have a brightness less than 128 after conversion to grayscale, but a solid bright green background would, so that tells you that you need to pin down more closely what you mean by "bright background"
0 Comments
See Also
Categories
Find more on Image Filtering and Enhancement in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!