How to define the boundary of a countour
Mostrar comentarios más antiguos
I am using this line of code to plot my contour of sea surface temperature, it is a rectangular box. [C1, h1] = contourf (X, Y, Z, [0:1:35], 'LineStyle', 'none' );
How do I trim off the areas that extends to the land with a polygon?
I tried to use "patch", but it does not work well, when the plot from the Atlantic Ocean is put together with the plots from other ocean basins.
Is there a way I can set X, Y, Z values (gridded data) to be NaN for the grids that are outside the polygon?

Thank you.
4 comentarios
Image Analyst
el 23 de Dic. de 2014
Editada: Image Analyst
el 23 de Dic. de 2014
Does this require the Mapping Toolbox? If so, list it below in the "Products" section.
Image Analyst
el 23 de Dic. de 2014
Editada: Image Analyst
el 23 de Dic. de 2014
Is your data an RGB image? Or is it in some other form? And explain "areas that extends to the land" - how do we know which pixels are land or not land? Do you have a binary image that defines land/not-land pixels?
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 23 de Dic. de 2014
Do you have the Image Processing Toolbox? If so, you can use poly2mask() to create a mask of land/not-land. Then you can mask the image.
% Mask the image using bsxfun() function
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, class(rgbImage)));
2 comentarios
Leon
el 23 de Dic. de 2014
Image Analyst
el 23 de Dic. de 2014
Then you can create a binary mask with a double for loop. You can still use bsxfun() to do the masking though - that does not require the toolbox.
Categorías
Más información sobre Oceanography and Hydrology en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

