How to change particular pixel color of a binary image to other color?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Asif Hasan
el 30 de Oct. de 2014
Comentada: Asif Hasan
el 31 de Oct. de 2014
Sir,
I have a binary image and i want to change the color of the black pixel to green. How do i do that ? Please help. Thanks in advance.
This is the binary image:
0 comentarios
Respuesta aceptada
Image Analyst
el 30 de Oct. de 2014
Try this:
%grayImage = imread('cameraman.tif');
%binaryImage = grayImage > 128;
%subplot(1,2,1);
%imshow(binaryImage);
redAndBlueChannel = 255 * uint8(binaryImage);
greenChannel = 255 * ones(size(binaryImage), 'uint8'); % Green Everywhere.
rgbImage = cat(3, redAndBlueChannel, greenChannel, redAndBlueChannel);
%subplot(1,2,2);
%imshow(rgbImage);
Remove the % if you want to demo it using a standard MATLAB demo image.
8 comentarios
Image Analyst
el 30 de Oct. de 2014
It works just fine. Here's proof:
s = load('binaryimage.mat')
binaryImage = s.show;
subplot(1,2,1);
imshow(binaryImage);
redAndBlueChannel = 255 * uint8(binaryImage);
greenChannel = 255 * ones(size(binaryImage), 'uint8'); % Green Everywhere.
rgbImage = cat(3, redAndBlueChannel, greenChannel, redAndBlueChannel);
subplot(1,2,2);
imshow(rgbImage);
Más respuestas (1)
Doug Hull
el 30 de Oct. de 2014
Change colormap?
clf
im = round(rand(10));
imshow(im)
colormap([0 1 0; 1 1 1])
Ver también
Categorías
Más información sobre Red en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!