P
P
Pavel K2017-12-23 20:34:12
Image processing
Pavel K, 2017-12-23 20:34:12

How to determine if an image is grayscale using Opencv?

Greetings!
It must be understood that the image is black and white (in grayscale) or color in the fastest way.
Please tell me this way.
PS the picture is originally RGB, iterate over each pixel and look at the threshold for too long.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2017-12-24
@PavelK

For a perfectly gray pixel, R=G=B will be true.
You can also convert RGB to HSV (Hue-Saturation-Value) and check the value of S. The ideal shade of gray in a pixel would be S=0. For a non-ideal gray (for example, scanning an A4 sheet in a scanner in RGB mode), the value of S will be close to 0.
Some calculate for each pixel
delta = abs(R-G) + abs(G-B) + abs(B-R)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question