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

1 次查看(过去 30 天)
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?

回答(1 个)

Walter Roberson
Walter Roberson 2016-2-28
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"

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by