Info
This question is closed. Reopen it to edit or answer.
Change specific colors in image to other colors
1 view (last 30 days)
Show older comments
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 Comment
Walter Roberson
on 5 May 2017
Duplicates https://www.mathworks.com/matlabcentral/answers/338924-change-specific-color-in-an-image-to-another-one
Answers (0)
This question is closed.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!