% clc; clear all; close all;
A = rgb2gray(imread('phua03.png'));
n1 = 120; n2 = 60; m = 5;
% for i = 1:n1
%     for j = 1:n2
%         datasetX = round(((i-1)/n1)*size(A,1))+1:round(i/n1*size(A,1));
%         datasetY = round(((j-1)/n2)*size(A,2))+1:round(j/n2*size(A,2));
%         B(datasetX,datasetY) = im2bw(A(datasetX,datasetY));
%     end
% end
% 
% B = edge(A);
% B = bwmorph(B,'fill');

B = ~im2bw(A);
C = bwmorph(B,'close');

subplot(1,2,1)
imshow(B)
subplot(1,2,2)
imshow(C)