Info
此问题已关闭。 请重新打开它进行编辑或回答。
Change specific colors in image to other colors
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2017-5-5
Duplicates https://www.mathworks.com/matlabcentral/answers/338924-change-specific-color-in-an-image-to-another-one
回答(0 个)
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!