Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Change specific colors in image to other colors

1 visualización (últimos 30 días)
Dries Weytjens
Dries Weytjens el 5 de Mayo de 2017
Cerrada: Walter Roberson el 5 de Mayo de 2017
Hi,
I am trying to change the color in an image to another color. The image that I am working on is attached in the question. I am trying to change all the purple data points to other colored data points, say green. I have already worked out some code that is capable of doing this, the only problem is that the edges of the purple data points remain purple-ish. I am not sure whether this is resolvable since I have tried zooming in on the points and I can see a lot of variations of purple around the core of the dot... My code is:
[I,m] = imread('/Users/Dries/Desktop/iteration31.png');
%image = imshow(I,'Colormap',m);
rgbImage = ind2rgb(I,m);
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
purplePixels = redChannel ==1 & greenChannel == 0 & blueChannel == 1;
% MAKE THEM GREEN
redChannel(purplePixels) = 0;
greenChannel(purplePixels) = 1;
blueChannel(purplePixels) = 0;
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
imshow(rgbImage);
  1 comentario
Walter Roberson
Walter Roberson el 5 de Mayo de 2017
Duplicates https://www.mathworks.com/matlabcentral/answers/338924-change-specific-color-in-an-image-to-another-one

Respuestas (0)

La pregunta está cerrada.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by