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

5 vues (au cours des 30 derniers jours)
Vecsei Gábor
Vecsei Gábor le 28 Fév 2016
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?

Réponses (1)

Walter Roberson
Walter Roberson le 28 Fév 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"

Catégories

En savoir plus sur Image Filtering and Enhancement dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by