Help with reading the RGB value of every pixel of a truecolor image using impixel
1 次查看(过去 30 天)
显示 更早的评论
Hi, I have a 16bit tiff that I want to get the RGB value from each pixel in the image. The image is a 3840x2160 16bit tiff. So, I ran the impixel command:
I= imread('sample.tif');
c = [1:3840,];
r = [1:2160,];
impixel(I,c,r)
but I get this error:
Error using impixel>parse_inputs (line 257)
Xi and Yi must have the same length.
Error in impixel (line 76)
[a,cm,xi,yi,x,y] = parse_inputs(varargin{:});
Error in pixel_get (line 4)
impixel(I,c,r)
Am I doing something wrong with the syntax for column or range? Or do you suggest doing this a different way?
Thanks
0 个评论
采纳的回答
Veda Upadhye
2017-11-14
Hi,
The error indicates that the vectors 'c' and 'r' should have the same length.
According to the documentation of impixel (https://www.mathworks.com/help/images/ref/impixel.html),
"impixel(I,c,r) returns the values of pixels specified by the row and column vectors r and c. r and c must be equal-length vectors. The kth row of P contains the RGB values for the pixel (r(k),c(k))."
For example, the following modification in your code would work.
I= imread('sample.tif');
c = [1:2160];
r = [1:2160];
impixel(I,c,r)
Hope this helped!
-Veda
更多回答(1 个)
Chris Loizou
2017-11-13
Hello,
yes well you are doing something wrong with sintax. Remove the comma from the brackets
if true
I= imread('sample.tif');
c = [1:3840];
r = [1:2160];
impixel(I,c,r)
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!