www.gusucode.com > images 案例代码 matlab源码程序 > images/FillRegionInGrayscaleImageExample.m
%% Fill Region in Grayscale Image % %% % Read grayscale image into the workspace. % Copyright 2015 The MathWorks, Inc. I = imread('eight.tif'); %% % Specify a polygon that completely surrounds one of the coins in the % image. This example uses the x-coordinates and y-coordinates (columns and % rows) of the polygon vertices to specify the region. x = [222 272 300 270 221 194]; y = [21 21 75 121 121 75]; %% % Fill the polygon, using the |regionfill| function. J = regionfill(I,x,y); %% % Display the original image and the filled image side-by-side. figure subplot(1,2,1) imshow(I) title('Original image') subplot(1,2,2) imshow(J) title('Image with one less coin')