Kamis, 07 Februari 2019
Matlab Edge Detection +Crop
rooftops = imread('daun.jpg');
imshow(rooftops);
grayImage = rgb2gray(rooftops);
imshow(grayImage);
[r c] = size(grayImage);
switchfactor = grayImage(round(r/2),round(c/2));
if switchfactor <= 120
minimumCanny = .0025;
maximumCanny = .05;
CFval = .6;
elseif switchfactor <= 150
minimumCanny = .005;
maximumCanny = .075;
CFval = .575;
elseif switchfactor <= 180
minimumCanny = .0075;
maximumCanny = .1;
CFval = .55;
elseif switchfactor <= 210
minimumCanny = .01;
maximumCanny = .125;
CFval = .525;
elseif switchfactor <= 240
minimumCanny = .0125;
maximumCanny = .15;
CFval = .5;
else
minimumCanny = .015;
maximumCanny = .2;
end
%%Active Contour (Overlaying mask and Contour) Works
imshow(grayImage);
hold on
mask = false(size(grayImage));
mask(20:end-20,20:end-20) = true;
visboundaries(mask,'Color','b');
bw = activecontour(grayImage, mask, 200, 'edge','ContractionBias',CFval);
visboundaries(bw,'Color','r');
title('Initial contour (blue) and final contour (red)');
figure, imshow(bw)
title('Segmented Image');
%%Reading the Contour and Specifying the roof
bwNew = grayImage;
bwNew(~bw) = 0;
figure;
imshow(bwNew);
E = entropyfilt(bwNew);
Eim =E;% rescale(E);
figure
imshow(Eim)
BW1 = imbinarize(Eim, .9);
imshow(BW1);
gI2 = bwNew;
gI2(BW1) = 0;
imshow(gI2)
BWf1 = edge(gI2,'canny',[minimumCanny, maximumCanny],sqrt(.075));
BWf2 = edge(bwNew,'canny',[minimumCanny, maximumCanny],sqrt(.075));
%BWf2 = edge(gI2,'zerocross',1,[20,100]);
figure;
imshowpair(BWf1,BWf2,'montage')
title('Textured Normal');
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar