How to change a pixel value of a RGB

31 次查看(过去 30 天)
I am trying to change a pixel value of a RGB image with the property '512*512*3 double'. I tried like gray scale images below
imagename(100,100) = [0.1,0.1,0.1];
or
imagename(100,100,1) = 1.0;
iamgename(100,100,2) = 0.1;
imagename(100,100,3) = 0.1;
The first one results more than original dimensions.. I have spent hours and so tried now.
The second one results redish image......
I'd be very appreciate with any help. Thanks.

回答(2 个)

José-Luis
José-Luis 2016-9-19
imagename(100,100,:) = [0.1, 0.1, 0.1];
Please read about indexing.

Image Analyst
Image Analyst 2016-9-19
Not sure what you're asking, but as you found out, the second way is correct. A color RGB image is a 3-D array with one color channel for red, one for green, and one for blue. Each color channel by itself is a 2-D image but when combined into an RGB image it becomes a 3-D array which takes 3 indexes, (row, column, colorChannelValue). To set a particular row and column to a value you have to use : and specify all three values
rgbImage(row, column, :) = [redValue, greenValue, blueValue];
Or you can do it one color channel at a time.
rgbImage(row, column, 1) = redValue;
rgbImage(row, column, 2) = greenValue;
rgbImage(row, column, 3) = blueValue;
But you can't do it like you did at first.

类别

Help CenterFile Exchange 中查找有关 Modify Image Colors 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by