From: cabrego on
I have a gray scale image that has been generated through a series of manipualation and mathematical operations and I would like to highlight particular pixel values

For example, one thing I would like to highlight (RED) pixel values in the image that are =>1, or maybe even in a particular range, 1>x>1.9.

How can I do this simple task...
From: ImageAnalyst on
% Demo to threshold an image and display the thresholded pixels as
red.

% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
clc;
clear all;
close all;
workspace;
% Read in standard MATLAB demo image.
grayImage = imread('cameraman.tif');
subplot(1, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', 20);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

% Threshold image
thresholdedImage = grayImage < 79;

% Get three monochrome images that will end up being the color planes.
redPlane = grayImage;
greenPlane = grayImage;
bluePlane = grayImage;

% Assign red to the thresholded part.
redPlane(thresholdedImage) = 255;
greenPlane(thresholdedImage) = 0;
bluePlane(thresholdedImage) = 0;

% Make a color version of the image

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

subplot(1, 2, 2);
imshow(rgbImage, []);
title('Thresholded Image, Red = < 79 Gray Levels', 'FontSize', 20);
From: cabrego on
Thanks for the reply works perfect.
From: cabrego on
I do have a question about what Matlab is doing here. I noticed while the pixels have been colored via RGB planes-there are quite a bit of additional that are black in the image and correspond to RGB 0 0 0.

How is matlab determining the color of non red pixels?
From: ImageAnalyst on
I don't know what you're talking about. Are you referring to my demo
code, or your code? In my code, the image is grayscale, so, other
than the pixels I colored red, every other pixel is just plain gray.
It could be anywhere from (0,0,0) to (255,255,255) but they're all
gray, just different intensities. What do you mean by "MATLAB
determining the color"? In my example, there's no "determining" - the
color is what it is, and that is gray. If it's your code and your
image, then you'd have to post both of those so we can take a look.