How can I get a mask matrix from a fill?

1 visualización (últimos 30 días)
Antonio Barrella
Antonio Barrella el 4 de Mzo. de 2019
Respondida: Chad Greene el 9 de Mzo. de 2019
Hello everyone!
I've been struggling with this problem for a while now. I have some SAR images in the form of longitude and latitude matrices. These are images of the ocean, and my task is to identify some areas on the ocean, areas that lie between two different level lines (depth). My task is to create a mask matrix that can only show me the area between the two level lines. So I thought about closing the layer lines in a polygon as shown here in the image, because my initial intention was to use the inpolygon function. This function, however, takes an unreasonable time, so I have to find another way.
Then I noticed that the fill function allows me to highlight the target area...
The problem is that the fill function works only on the graphic part, I would like to know if there is a way to use the fill function in order to build a mask matrix useful to filter from the longitude and latitude matrices only the value in that zone.
Can someone help me? Thanks in advance!
The code is:
%Given MatrLon and MatrLat, I want to work with arrays:
VectLon=reshape(MatrLon,1,[]);
VectLat=reshape(MatrLat,1,[]);
%At this point I can display the image ad a rectangle:
figure
scatter(VectLon,VectLat)
axis([-6 3 44 52])
hold on
%Once I've computed the -5 m and -70 m isolines, I can create a closed
%polygon as follow:
xv=[xdata5 xdata70 xdata5(1)];
yv=[ydata5 ydata70 ydata5(1)];
%At this point I can display the polygon on the image:
plot(xv,yv)
xlabel('longituge')
ylabel('latitude')
legend('image pixel','iso-Depth polygon')
%Now I would like to have a mask matrix in order to filter only points with
%(lat,lon) coordinates inside the polygon, but I have tried inpolygon
%function and it takes too long.
A = fill(xv,yv,'r')
%With fill function I can see the area that I would like to filter, but...
%How can I use the patch object A in order to get a mask matrix?
  3 comentarios
Antonio Barrella
Antonio Barrella el 4 de Mzo. de 2019
You're right, I have just inserted the code!
Rik
Rik el 4 de Mzo. de 2019
There is still no test data attached (or code to generate dummy data).

Iniciar sesión para comentar.

Respuestas (1)

Chad Greene
Chad Greene el 9 de Mzo. de 2019
Perhaps you want to use inpolygon to get a mask of grid cells within the polygon?

Categorías

Más información sobre Elementary Polygons en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by