Adjusting color limits on displayed color images

14 Ansichten (letzte 30 Tage)
Alaster Meehan
Alaster Meehan am 26 Aug. 2024
Kommentiert: Walter Roberson am 26 Aug. 2024
When displaying a color image is it possible to set the limits of the cData. The below dcoumentation states that if a double is given then the limits range from 0 to 1 with different values for int8 etc.
Is it possible to change what these limits are, ideally with different values for each channel. Currently my solution is to scale the origional data before senging it to image(), but this is slow to do each time the user wants to adjust these scale values to highlight different parts of the data. It also prevents tools like impixelinfo from giving correct values. Also if there are any other features that are plotted such as boxes then these also need to be redone. Zoom ranges and everything else also need to be preserved. This all becomes a big hassle and affects performance if the user is regulary changing the intensity scales.
How are these limits set? CLim seems to have no effect, neither do the colormaps.
Is it possible to set the black and white values of a displayed image through some undocumented feature?
Cheers Alaster
  • 3-D array of RGB triplets — This format defines true color image data using RGB triplet values. Each RGB triplet defines a color for one pixel of the image. An RGB triplet is a three-element vector that specifies the intensities of the red, green, and blue components of the color. The first page of the 3-D array contains the red components, the second page contains the green components, and the third page contains the blue components. Since the image uses true colors instead of colormap colors, the CDataMapping property has no effect.
  • If CData is of type double, then an RGB triplet value of [0 0 0] corresponds to black and [1 1 1] corresponds to white.
  • If CData is an integer type, then the image uses the full range of data to determine the color. For example, if CData is of type uint8, then [0 0 0] corresponds to black and [255 255 255] corresponds to white. If CData is of type int8, then [-128 -128 -128] corresponds to black and [127 127 127] corresponds to white.
  • If CData is of type logical, then [0 0 0] corresponds to black and [1 1 1] corresponds to white.

Antworten (1)

Image Analyst
Image Analyst am 26 Aug. 2024
What data type do you have for your indexed image? If it's double, it should be in the range 0-1, and if it's uint8 it should be in the range 0-255. Your Nx3 colormap matrix should always be in the range 0-1 no matter what type of variable your image (CData) is.
If you have a double not within the range 0-1 then you will either have to convert it to the range 0-1 with (I believe) mat2gray. If it's integer outside of the range 0-255, like it's uint16 in the range 0-65535, then it should also work.
Once your image is put into ax axes with imshow or image, then you should be able to quickly change and apply a new colormap very quickly. There is no need to transform the image every time once it's been put into the axes control.
clim does not affect the colormap but what it does is to say what value of your data should use upper and lower rows of your colormap. For example if your colormap goes from black to red, and your data goes from 0.3 to 0.7, then you can use clim to say that you want everything from 0 to 0.5 to be black, and everything above 0.6 to be red, and the range 0.5 to 0.6 to be what your colormap is. For example if you have 64 indexed colors, the 64 colors would apply to pixels in the range 0.5-0.6 and everything less than 0.5 would use the color in the first row of the colormap array and everything above 0.6 would appear as the color in the 64th row of the colormap matrix. Using colormap to apply a new colormap matrix, or using clim to change the limits should be virtually instant.
  5 Kommentare
Image Analyst
Image Analyst am 26 Aug. 2024
Like DGM said, clim() does not apply for true color, three channel, RGB images. A colormap is only for turning a gray scale into a color, not for turning one RGB color into a different RGB color.
If you want to highlight something, like make it a different color or superimpose a colored overlay on top of it, you can segment the region you want to highlight by whatever means you need to (so that you now have a binary image, mask), and then use imoverlay or labeloverlay to apply that segmented mask to the image.
Walter Roberson
Walter Roberson am 26 Aug. 2024
Consider using rgb2ind to convert to an indexed image; after that, adjust the colormap dynamically as necessary.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Produkte


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by