i wanted to display binary image in blue color....

i wanted to display binary image in blue color... the code i worked with is...
global image
I= im2bw(image);
axes(handles.axes4);
imshow(I)
colormap([0 0 1; 1 1 1])
axis equal;axis off;
the pblm i'm facing is.. when i execute this code it is coming corectly, but it is altering the other images in axes1,2,3 also to blue color.... i want only axes4 image to be displayed in blue color....
why is it coming like that....what shud i do???please reply....
[EDITED, code formatted, Jan]

 Accepted Answer

Image Analyst
Image Analyst on 31 Oct 2012
Edited: Jan on 31 Oct 2012
blankImage = zeros(size(binaryImage));
rgbImage = cat(3, blankImage , blankImage , binaryImage);
DON'T use image as the name of your variable because it's a built-in function name!!!

5 Comments

thanks sir... its working...the image is being displayed in a blue background.... but i wanted the image to be displayed in blue...suppose i binarize a barcode image... i want the black lines of barcode to be displayed in blue in a white background...
@Elysi: Do you mean something like this:
blankImage = ones(size(binaryImage));
rgbImage = cat(3, blankImage, blankImage, not(binaryImage))
"display image in blue" is not a really helpful descritpion of what you want. Image Analyst's answer contains the required techniques, so please feel free to experiment with them until you can solve your problem.
thanks sir... the image is being displayed in black background... can the background color be changed to white sir??please reply sir..
Is this what you want:
% Assume binary image is false where the bars are black.
% Extract the individual red, green, and blue color channels.
redChannel = originalRGBImage(:, :, 1);
greenChannel = originalRGBImage(:, :, 2);
blueChannel = originalRGBImage(:, :, 3);
% Make it blue where the bars are.
redChannel (~binaryImage) = uint8(0);
greenChannel(~binaryImage) = uint8(0);
blueChannel (~binaryImage) = uint8(255);
% Combine individual masked channels into a new RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
thank u so much sir....

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!