Colorbars of image in matab

3 次查看(过去 30 天)
Kaushal Kishore
Kaushal Kishore 2018-9-10
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.

回答(2 个)

Walter Roberson
Walter Roberson 2018-9-11
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 2018-9-11
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.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by