How can i Change pixel color?
44 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ansam Nazar
am 7 Jul. 2020
Kommentiert: Image Analyst
am 12 Jul. 2020
Hello
I have a color image of type RGB and I need to change the color of each point (red, yellow, orange) to green. I hope that there is a programmatic solution to this problem.
5 Kommentare
Mehmed Saad
am 8 Jul. 2020
jonas is right, understand the code and try to replace for loops with logical indexing
Akzeptierte Antwort
Mehmed Saad
am 7 Jul. 2020
Bearbeitet: Mehmed Saad
am 8 Jul. 2020
I = imread('red.jpg');
figure,subplot(121),imshow(I)
th = 20;
[x,y,~]=size(I);
for ii=1:x
for jj=1:y
if((I(ii,jj,1)-th)> I(ii,jj,2)&& (I(ii,jj,1)-th)>I(ii,jj,3))
I(ii,jj,1) = 0;I(ii,jj,2) = 255;I(ii,jj,3) = 0;
end
end
end
subplot(122),imshow(I)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/328235/image.png)
For same effect you can try this
I(ii,jj,1:2) = circshift(I(ii,jj,1:2),1);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/328673/image.png)
I(:,:,1:2) = circshift(I(:,:,1:2),1,3);%without for loop
4 Kommentare
Image Analyst
am 12 Jul. 2020
You can do it manually:
r = rgbImage(:, :, 1);
g = rgbImage(:, :, 2);
b = rgbImage(:, :, 3);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!