Borrar filtros
Borrar filtros

Can anyone correct this code for the crack detection in irrigation canal?

1 visualización (últimos 30 días)
clc;
clear;
close all;
%%step 1
image = imread('D:/canal images/crack.jpg');
%image = imread('C:/Users/Jainee/Documents/MATLAB/frame60.jpg');
figure
imshow(image);
%%step 2
gray = rgb2gray(image);
imshow(gray);
title('Gray Scale');
%%step 3
croped = imcrop(gray);
figure
imshow(croped);
title('Croped Image');
%%step 4
sharpen = imsharpen(croped,'Amount',3);
figure
imshow(sharpen);
title('Sharped Image');
%%step 5
se = strel('Line',100,90); %%create a disk-shaped structring element
% bothat = imsubtract(imadd(sharpen,imtophat(sharpen,se)),imbothat(sharpen,se)); %%applying bottom hat method
bothat=imbothat(sharpen,se);
figure
imshow(bothat);
title('Bottom Hat Method');
%%step 6
level = graythresh(bothat); %%return gary level of image
BW = im2bw(bothat,level); %%convert into binary
figure
imshow(BW);
title('Binary Image');
bw5 = bwareaopen(BW,80,8);
figure
imshow(bw5)
%%title('Size range: 20-50 pixels')
bwt5=BW-bw5;
figure
imshow(bwt5);
se2=strel('disk',2);
%
bw6=imclose(bwt5,se2);
figure
imshow(bw6);
bw18=bw6;
si = size(croped);
for i=1:si(1)
for j=1:si(2)
if(bw18(i,j)==1)
new_image(i,j,1)=255;
new_image(i,j,2)=0;
new_image(i,j,3)=0;
else
new_image(i,j,:)=croped(i,j,:);
end
end
end
figure
imshow(new_image);

Respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by