Three dimensional arrays with poly2mask in each page

3 vues (au cours des 30 derniers jours)
Martha
Martha le 24 Août 2014
Commenté : Martha le 25 Août 2014
Hi,
I need to create several poly2mask that are of size 612x924 I'm trying to do that with a for loop, I create a matrix 612x924x5 before the loop to save the variable.
But it doesn't work, it retrieve an "Error using poly2mask Too many input arguments" I did this:
polygons=zeros(612,924,count);
for w=1:1:count;
polygons(w)=poly2mask(x(:,w),y(:,w),sf(1),sf(2),w);
end
Does someone knows a better way to create this?, Or perhaps to save each polygon in a new variable?
Thank you, Martha

Réponse acceptée

Geoff Hayes
Geoff Hayes le 25 Août 2014
Martha - according to poly2mask, there are only four inputs to this function. You have specified five, so the error message Error using poly2mask Too many input arguments makes sense.
Your code is almost correct, it is just the assignment (and additional fifth parameter) that needs some work. Perhaps the following with do the trick
polygons=zeros(612,924,count);
for w=1:1:count;
polygons(:,:,w)=poly2mask(x(:,w),y(:,w),sf(1),sf(2));
end
Try the above and see what happens!
  1 commentaire
Martha
Martha le 25 Août 2014
Thank you for the explanation Geoff, now make sense...

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 25 Août 2014
polygons is a 3D array, not a 1D array so you can't stick a whole 2D plane/slice into a single element. Try this
polygons(:,:,w) = poly2mask(...............
  1 commentaire
Martha
Martha le 25 Août 2014
Thank you Image Analyst, it worked very well!

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by