From: cabrego on
My code is below and it is basically just taken from what you posted.

R is a 2D matrix of double values. I suppose one thing I would like to do is clean up the image, by perhaps making certain values white. I think this wouldrequire an additional threshold on R, see comment below for thresholdedImage2. hope this makes sense...


thresholdedImage=R>=.96 & R<=1.05;

%thresholdedImage2=R<=.96 & R>=1.05;%not sure how to make these white


% Get three monochrome images that will end up being the color planes.
redPlane =R;
greenPlane =R;
bluePlane =R;
% Assign red to the thresholded part.
redPlane(thresholdedImage) = 255;
greenPlane(thresholdedImage) =0;
bluePlane(thresholdedImage) = 0;

%insert threshold image2 planes here

% Make a color version of the image

rgbImage = cat(3, redPlane, greenPlane, bluePlane);

figure
imshow(rgbImage, []);
title('Thresholded Image');
From: ImageAnalyst on
Can't you just say:

redPlane(~thresholdedImage) = 255;
greenPlane(~thresholdedImage) =255;
bluePlane(~thresholdedImage) = 255;

This will set all pixels, except those you set to red, to be white.
From: cabrego on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <d1a90722-7a51-4d21-bc41-b878380b4ca4(a)t41g2000yqt.googlegroups.com>...
> Can't you just say:
>
> redPlane(~thresholdedImage) = 255;
> greenPlane(~thresholdedImage) =255;
> bluePlane(~thresholdedImage) = 255;
>
> This will set all pixels, except those you set to red, to be white.


ImageAnalyst, I inserted the 3 lines (not replacing the existing ones) and it worked as you stated. Can you recommend a reference or resource to understand what exactly I am doing. I don't quite understand what is happening...

Thanks!
From: ImageAnalyst on
Look up "logical indexing" in the help. Basically if you pass the
index as a logical array, it will only do the assignments for those
indexes that are true. Since you had a logical image,
thresholdedImage, which was true where you wanted red and false where
you didn't want red, I just inverted it with the tilde character. So
~thresholdedImage is true where you don't have red and that is where
it will make it white by setting all three color planes to 255 for
those pixels.