![0000 Screenshot.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/204370/0000%20Screenshot.png)
problem of color display in an image
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
dakhli mohamed
el 15 de Feb. de 2019
Respondida: Image Analyst
el 16 de Feb. de 2019
hello i have a display problem i want to convert the black color in the image attached to the red color
here is the code that I wrote
maps = load('img.mat');
fetrain = struct2array(maps);
imshow(fetrain)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/204317/image.jpeg)
0 comentarios
Respuesta aceptada
Image Analyst
el 16 de Feb. de 2019
Try this:
s = load('img.mat')
rgbImage = s.img;
subplot(1, 2, 1);
imshow(rgbImage)
impixelinfo
title('Original Image', 'FontSize', 20);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
blackMask = redChannel == 0 & greenChannel == 0 & blueChannel == 0;
redChannel(blackMask) = 255;
greenChannel(blackMask) = 0;
blueChannel(blackMask) = 0;
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
subplot(1, 2, 2);
imshow(rgbImage);
title('Now with black made red', 'FontSize', 20);
![0000 Screenshot.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/204370/0000%20Screenshot.png)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Colormaps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!