Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Change specific colors in image to other colors

1 回表示 (過去 30 日間)
Dries Weytjens
Dries Weytjens 2017 年 5 月 5 日
閉鎖済み: Walter Roberson 2017 年 5 月 5 日
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
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!

Translated by