Help with reading the RGB value of every pixel of a truecolor image using impixel
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ChickenHunter
le 9 Nov 2017
Commenté : ChickenHunter
le 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 commentaires
Réponse acceptée
Veda Upadhye
le 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
Plus de réponses (1)
Chris Loizou
le 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 commentaires
Voir également
Catégories
En savoir plus sur Explore and Edit Images with Image Viewer App dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!