简体   繁体   中英

In matlab, colormap has no effect on image

I am trying to convert an image I have to have a concentration-ish look using matlab. I want it show a range of concentration values for the green part of the image, shown below:

在此输入图像描述

I load in the image and try to change the color map:

>> ex1 = imread('C:\Users\Tyler\Documents\Dropbox\ex1.png');
>> imshow(ex1)
>> colormap(grey)

This changes what the colorbar looks like, but has absolutely no affect on the image itself. It is still green with the purple below it. Why does this not change the image, in the way that just changing the colormap in documentation does.

Tyler

The colormap only has an impact on monochrome data. Presumably it's an RGB PNG file, so it will have no effect here. Use rgb2gray on ex1 first.

If the image is an RGB PNG file you can extract just one channel (red: ex1(:,:,1) , green: ex1(:,:,2) , blue: ex1(:,:,3) ) and plot it using imagesc(ex1(:,:,1)) . Now it should be possible to choose your favourite colormap .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM