Colorbars of image in matab

2 visualizzazioni (ultimi 30 giorni)
Kaushal Kishore
Kaushal Kishore il 10 Set 2018
Risposto: Image Analyst il 11 Set 2018
Hi i have a image in .JPG format. I have imported the image into matlab and have used the imshow command to plot the image. Know i want to display the color-bar containing the same colors in the image. I am using MATLAB R2015a. Can anyone suggest any codes which i can use.

Risposte (2)

Walter Roberson
Walter Roberson il 11 Set 2018
No, that is not possible.
In order to draw a colorbar you have to have a scalar value for each distinct color. You arrange the scalar values in order and draw the corresponding color at the correct relative position according to the scalar values, and call the result a colorbar.
However you can never do that for color jpeg. Jpeg supports scalar values at positions for grayscale (though this is very rare to encounter in practice), and jpeg supports RGB in which there are three values per pixel (not a scalar). Jpeg does not support indexed (colormapped) images, which is a system of linear values per pixel and an associated colormap indicating which color is associated with which pixel.
So color jpeg are never composed of scalar values, only of triplets per pixel. Therefore you cannot associate a scalar with each location as required to construct a colorbar.

Image Analyst
Image Analyst il 11 Set 2018
You need to use the function colorcloud(). This will show you the 3 dimensional color gamut of your image. The complete color gamut cannot be shown in a bar, it has to be shown in a scatterplot-like format like colorcloud() gives you.

Community Treasure Hunt

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

Start Hunting!

Translated by