1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
clc;
close all;
clear all;
image = imread('lettre2_8.jpg');
image = im2bw(image,graythresh(image));
[x,y] = size(image);
for i=1:x
for j=1:y
if ((j>1) & (j <= image(:,end)))
if ((image(i,j) == 1) && ((image(i,j-1)== 0) || (image(i,j+1)== 0)))
pixNoirCote =0;
if (image(i,j-1) == 0)
pixNoirCote = pixNoirCote + 1;
end
if (image(i,j+1) == 0)
pixNoirCote = pixNoirCote + 1;
end
if (image(i+1,j) == 0)
pixNoirCote = pixNoirCote + 1;
end
if (image(i-1,j) == 0)
pixNoirCote = pixNoirCote + 1;
end
if pixNoirCote >=3
image(i,j)= 0;
end
end
end
end
end
imwrite(image,'lettreeuhhhh.jpg','jpg','Quality',100); |
Partager