How can I detect if the backgroud is brighter than the coins or it's darker?

4 Ansichten (letzte 30 Tage)
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?

Antworten (1)

Walter Roberson
Walter Roberson am 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"

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by