Subscript indices must either be real positive integers or logicals
Mostra commenti meno recenti
I am trying to move values from an array to another. In particular I am taking the value of the red, green and blue of the specific pixel of the image using the command
img(x,y,:) %where img is my image
and I want to put it in an array defined as pix1 = zeros(3,1). When I do the simple equation pix1(:,1) = img(x,y,:) I get the error ' Subscript indices must either be real positive integers or logicals'. If I understood well this is due to the fact that the rgb values are floats? How do I get to put them in the array pix1 without rounding the value?
Thanks
5 Commenti
Geoff Hayes
il 25 Ott 2017
Elena - the RGB values (from your img matrix) can be floats but I think the error is more due to the x and y indices which you are using to access the data in img. How are these two variables being initialized? What are their values?
EL
il 25 Ott 2017
Geoff Hayes
il 25 Ott 2017
Yes, the indices must be greater than zero (positive integers). Why is x becoming zero?
EL
il 25 Ott 2017
Geoff Hayes
il 25 Ott 2017
yes, that should work.
Risposte (1)
Andrei Bobrov
il 25 Ott 2017
Modificato: Andrei Bobrov
il 25 Ott 2017
pix1 = reshape(img(x,y,:),[],1);
Categorie
Scopri di più su Image Arithmetic in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!