Matlab colormap - How to change only one value, not a range of values?

This is my first StackOverflow question, so forgive me if I make some mistakes.

I need to render several single-channel images (2D matrices) using MATLAB. The value of each pixel is usually in the range of ~10^-10and ~10^-6. I use flipped jetcolormap (so dark red is low and blue is high).

Now some of these matrices also contain some pixel values 0. I would like to set a specific color (say white) only for these pixels. At the moment, I have done the following:

cmap = colormap('jet'); % standard 64 colors jet colormap 
cmap = flipud(cmap);

Then I tried to edit the first line of the color map and set it to [1 1 1](white), following the various answers I found on the Internet (including How to change one color in colcolap in Matlab? ):

cmap(1,:) = [1 1 1];
colormap(cmap);

The problem is that this change in the color map sets the first values ​​of the / 64 range (I think) of the image to white, instead of setting only the tags 0to white.

I was wondering: is it possible to set only these pixels to white?

I believe that my problem depends on the fact that even for images with these few 0valuable pixels, the second smallest pixels are many and really small (in order 10^-10).

! !

Ujin

+4
1

, logical, 0 .

, 2D-, , jet ind2rgb. 0 , . . , , , 0, . , , , , , , . , , .

, im, :

cmap = colormap('jet'); % standard 64 colors jet colormap 
cmap = flipud(cmap);
im2 = im;
ind = im == 0; %// Find locations that are zero in the original image
im2(ind) = max(im(:)); %// Make a copy of the original image where 0 pixels are set to the maximum of the image
rgb = ind2rgb(im2, cmap); %// Create pseudo-coloured image
rgb(repmat(ind, [1 1 3])) = 1; %// Set corresponding locations to white

imshow, Image Processing Toolbox, image (.. imshow(rgb) image(rgb)).

cmap = colormap('jet'); cmap = jet;, colormap('jet') , . cmap = jet; .

+1

All Articles