Help with reading the RGB value of every pixel of a truecolor image using impixel
1 view (last 30 days)
Show older comments
ChickenHunter
on 9 Nov 2017
Commented: ChickenHunter
on 14 Nov 2017
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 Comments
Accepted Answer
Veda Upadhye
on 14 Nov 2017
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
More Answers (1)
Chris Loizou
on 13 Nov 2017
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 Comments
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!