Filter löschen
Filter löschen

how can i extract data between 4 points in a matrix?

2 Ansichten (letzte 30 Tage)
Maayan
Maayan am 1 Okt. 2013
Kommentiert: Maayan am 1 Okt. 2013
I have a matrix and 4 vertices of a rectangle. The rectangle is not aligned with the axes,i.e the rectangle is slanted. I want to extract the data between the 4 vertices into a new matrix. How can i do it? I've been trying to do it for weeks. Thanks

Antworten (1)

Image Analyst
Image Analyst am 1 Okt. 2013
Weeks? Wow. Do yo have the Image Processing Toolbox? If so, you can simply use poly2mask():
[rows, columns] = size(your2Darray);
logicalMap = poly2mask(x, y, rows, columns); % put in coords of the rectangle corners.
extractedValues = your2Darray(logicalMap);
  1 Kommentar
Maayan
Maayan am 1 Okt. 2013
Yes weeks,I know it's a long time- I'm new with programming codes and i'm new with matlab. In your second line you wrote columns and rows- do you mean the number of columns and rows in my rectangle? All i have is the 4 vertices of the slanted rectangle so i don't know how to calculate the number of columns and rows in it.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by