MATLAB Answers

0

How to change a pixel value of a RGB

Asked by Bong Kyu Choung on 19 Sep 2016
Latest activity Answered by Image Analyst
on 19 Sep 2016
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.

  0 Comments

Sign in to comment.

2 Answers

Answer by José-Luis
on 19 Sep 2016

imagename(100,100,:) = [0.1, 0.1, 0.1];
Please read about indexing.

  0 Comments

Sign in to comment.


Answer by Image Analyst
on 19 Sep 2016

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.

  0 Comments

Sign in to comment.