how write a code to know the color of image using matlab?(how to identify a color from an image)

11 vues (au cours des 30 derniers jours)
I am a beginner in using matlab , for example if i add image of date fruit to matlab and i want to determines which is color of image ? can it use threshold,
the color component should be the output eg-if the color of the image is brown or red i need the output brown or red. if the color is burgundy red,or crimson,or any mix output should say its presence. i tried documentation on matlab but could understand like how to specifically apply specification and thresholding.
  2 commentaires
Walter Roberson
Walter Roberson le 29 Sep 2019
Define "red". Define "brown". Define "burgundy red". Define "crimson".
These are serious questions, and it turns out they are pretty hard to answer. Is RGB [1/256, 0, 0] red? Is RGB [254/256, 0, 1/256] red?
KALYAN ACHARJYA
KALYAN ACHARJYA le 29 Sep 2019
Modifié(e) : KALYAN ACHARJYA le 29 Sep 2019
Thanks @Walter Sir, got it

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 29 Sep 2019
Cameras do not detect color.
A small portion of cameras use diffraction gratings to separate light into it's component frequency bands, and then those cameras use a whole bunch of narrow slits to measure intensity across narrow bands. But those are not common, and they seldom record "scenes", and they do not tell you what color a human eye would perceive.
Most cameras split the light into three, directing it into three different filters, each of which peaks at a different wavelength. The filters are not narrow band: it is deliberate that they overlap, and that the filter attenation is to different degrees for the same bandwidth across the three filters. The intensity of the light is integrated for a short time for each filter, and the results are quantized, most often into 1/256 increments (but there are other possibilities.) [To be more accurate, the split is more often into four filters, two of which are the same range; this reflects the fact that the human eye is much more sensitive to one of the frequency ranges.]
So you get out relative intensities over that time for the three different filter bins. But it takes work to interpret that as "color". The fact that the bins overlap becomes important, as it helps differentiate between the intensity readings being due to more photons per second (brighter) versus the intensity readings being due to higher energy photons (frequency): if you had a single pure source of a particular frequency, then by knowing how the filters attenuate by frequency and knowing the relative intensity measured by two adjacent bins, you can estimate where the peak frequency is.
But... it isn't especially accurate. And light is seldom pure frequencies. And it turns out that the brain does automatic color perception adjustment according to brightness level, so that if we see a "red" ball in sunlight and it bounces into shadow (different illuminating frequency) then the human brain continues to perceive the ball as continuing to be "red". Furthermore the same thing happens over a range of different illumination mixes: you still perceive the ball as "red" if you bring it inside and put it under a florescent bulb for example. There are limits, though: if you look at yourself under a low pressure sodium vapour lamp such as was once common for street lamps, then you will likely perceive yourself in shades of yellow and purple and black. But remember that your inherent color has not changed: the now oddly-purple/black red ball you have is still "red" even though it does not look at all "red".
Thus it becomes very difficult to decide what the "color" is of something based upon a single RGB image. There are other color systems that do a better job of describing inherent color and modeling the effect of illunination. "Colorimeters".

Image Analyst
Image Analyst le 2 Août 2022
See my attached demo. You can train it with colors that you define by tracing outlines over those colors in the region. Then the demo uses discriminant analysis to classify every pixel in the image into one of the colors you specified.

Catégories

En savoir plus sur Image Processing Toolbox 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