Hello,
I am trying to change colors in an image into another color. I have generated some code myself but something seems to be wrong. What I am trying to achieve on the attached file is to change every purple data point into a green data point, or whatever color I would prefer. Currently, the code that I have written is able to change purple to green but the edges of the marked points are still in purple, I believe this has something to do with the intensity at the edges being different or something…
[I,m] = imread('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);
Best Answer