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.
0 件のコメント
回答 (2 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Modify Image Colors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!