Escolar Documentos
Profissional Documentos
Cultura Documentos
Exercício de PI
Exercício de PI
Script:
I = imread('coins.png');
imshow(I)
sobel = edge(I,'sobel');
canny = edge(I,'canny');
zc = edge(I,'zerocross');
prewitt = edge(I,'prewitt');
log = edge(I,'log');
figure;
imshow(sobel);
title('Sobel');
figure;
imshow(canny);
title('Canny');
figure;
imshow(zc);
title('Zero Cross');
figure;
imshow(prewitt);
title('Prewitt');
figure;
imshow(log);
title('LOG');
//2-----------------------------------------------------------
Script:
I = imread('coins.png');
imshow(I)
J = histeq(I);
figure;
imshow(J);
sobel1 = edge(J,'sobel');
canny1 = edge(J,'canny');
zc1 = edge(J,'zerocross');
prewitt1 = edge(J,'prewitt');
log1 = edge(J,'log');
figure;
imshow(sobel1);
title('Sobel1');
figure;
imshow(canny1);
title('Canny1');
figure;
imshow(zc1);
title('Zero Cross1');
figure;
imshow(prewitt1);
title('Prewitt1');
figure;
imshow(log1);
title('LOG1');
K = adapthisteq(I);
figure;
imshow(K);
sobel2 = edge(K,'sobel');
canny2 = edge(K,'canny');
zc2 = edge(K,'zerocross');
prewitt2 = edge(K,'prewitt');
log2 = edge(K,'log');
figure;
imshow(sobel2);
title('Sobel2');
figure;
imshow(canny2);
//3-------------------------------------------------------------
Script:
I = imread('coins.png');
imshow(I);
s1 = imgaussfilt(I,1);
figure;
imshow(s1);
s2 = imgaussfilt(I,2);
figure;
imshow(s2);
s3 = imgaussfilt(I,3);
figure;
imshow(s3);
sobel1 = edge(s1,'sobel');
canny1 = edge(s1,'canny');
zc1 = edge(s1,'zerocross');
prewitt1 = edge(s1,'prewitt');
log1 = edge(s1,'log');
figure;
imshow(sobel1);
title('Sobel1');
figure;
imshow(canny1);
title('Canny1');
figure;
imshow(zc1);
title('Zero Cross1');
figure;
imshow(prewitt1);
title('Prewitt1');
figure;
imshow(log1);
title('LOG1');
sobel2 = edge(s2,'sobel');
canny2 = edge(s2,'canny');
zc2 = edge(s2,'zerocross');
prewitt2 = edge(s2,'prewitt');
log2 = edge(s2,'log');
figure;
imshow(sobel2);
title('Sobel2');
figure;
imshow(canny2);
title('Canny2');
figure;
imshow(zc2);
title('Zero Cross2');
figure;
imshow(prewitt2);
title('Prewitt2');
figure;
imshow(log2);
title('LOG2');
sobel3 = edge(s3,'sobel');
canny3 = edge(s3,'canny');
zc3 = edge(s3,'zerocross');
prewitt3 = edge(s3,'prewitt');
log3 = edge(s3,'log');
figure;
imshow(sobel3);
title('Sobel3');
figure;
imshow(canny3);
title('Canny3');
figure;
imshow(zc3);
title('Zero Cross3');
figure;
imshow(prewitt3);
title('Prewitt3');
figure;
imshow(log3);
title('LOG3');
//4-------------------------------------------------------------------------
Script:
I = imread('coins.png');
imshow(I);
background = imopen(I,strel('disk',15));
figure;
surf(double(background(1:8:end,1:8:end))),zlim([0 255]);
set(gca,'ydir','reverse');
I2 = I - background;
figure;
imshow(I2);
I3 = imadjust(I2);
figure;
imshow(I3);
bw = imbinarize(I3);
bw = bwareaopen(bw, 50);
figure;
imshow(bw);
cc = bwconncomp(bw, 4);
graindata = regionprops(cc, 'basic');
grain_areas = [graindata.Area];
[max_area, idx] = max(grain_areas)
figure;
histogram(grain_areas);