How can I get a mask matrix from a fill?
1 次查看(过去 30 天)
显示 更早的评论
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/206763/image.png)
Then I noticed that the fill function allows me to highlight the target area...
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/206768/image.png)
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 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Elementary Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!