poly2maskfine
Versión 1.0.0 (2,28 KB) por
Dirk-Jan Kroon
Computes an anti-aliased mask from a polygon, like poly2mask but then accurate anti aliased
poly2maskfine Computes an anti-aliased mask from a polygon.
GrayMask = poly2maskfine(X, Y, M, N) computes an accurate anti-aliased mask
representing the polygon defined by the vertices in vectors X and Y.
The output GrayMask is a double array of size M x N:
- Pixels on the edge of the polygon are set to a value representing
the area of overlap between the polygon and the pixel's square area.
- Pixels inside the polygon (defined by X and Y) are set to 1.
- Pixels outside the polygon (defined by X and Y) are set to 0.
poly2maskfine automatically closes the polygon if it's not already closed.
Example:
% Create a 100x120 grayscale image
M = 100; N = 120;
% Create an ellipse
theta = linspace(0, 2*pi, 100); % 100 points for the circle contour
x_ellipse = 60 + 55 * cos(theta); % x coordinates of the circle contour
y_ellipse = 50 + 40 * sin(theta); % y coordinates of the circle contour
% Compute the anti-aliased mask for the ellipse
GrayMask = poly2maskfine(x_ellipse, y_ellipse, M, N);
figure, imshow(GrayMask)
Citar como
Dirk-Jan Kroon (2024). poly2maskfine (https://www.mathworks.com/matlabcentral/fileexchange/164491-poly2maskfine), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Se creó con
R2024a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS LinuxEtiquetas
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
Versión | Publicado | Notas de la versión | |
---|---|---|---|
1.0.0 |