Crack Detection
I have problem for detection for surface ceramics image, how i can detect crack surface , pls give me some advice. this my code for detect crack surface
function [img1_array, img2_array,img3_array, img4_array,Zme]= DefectScan(input_path,input_path2);
% clear all;
% close all;
I = imread(input_path2);
J = imread(input_path);
I = rgb2gray(I);
J = rgb2gray(J);
% f=figure,imshow(I);
% g=figure,imshow(J);
hy = fspecial(‘sobel’);
hx = hy’;
Iy = imfilter(double(I), hy, ‘replicate’);
Ix = imfilter(double(I), hx, ‘replicate’);
ey = fspecial(‘sobel’);
fx = ey’;
Jy = imfilter(double(J), ey, ‘replicate’);
Jx = imfilter(double(J), fx, ‘replicate’);
gradmag = sqrt(Ix.^2 + Iy.^2);
gradmag2 = sqrt(Jx.^2 + Jy.^2);
K=figure,imshow(gradmag,[]);
L=figure,imshow(gradmag2,[]);
set(K, ‘visible’,’off’);
set(L, ‘visible’,’off’);
filename = ‘temp_file.jpg’
filename2 = ‘temp_file2.jpg’
saveas(K, filename)
saveas(L, filename2)
i1 = imread(filename)
i2 = imread(filename2)
delete(filename)
delete(filename2)
[x, y, rgb] = ind2sub([size(i1,1) size(i1,2) size(i1,3)], find(i1 ~= 255));
A = i1(min(x):max(x)-1,min(y):max(y)-1,:);
[x, y, rgb] = ind2sub([size(i2,1) size(i2,2) size(i2,3)], find(i2 ~= 255));
B = i2(min(x):max(x)-1,min(y):max(y)-1,:);
A = rgb2gray(A)
B = rgb2gray(B)
I = edge(A,’sobel’)
J = edge(B,’sobel’)I have problem for detection for surface ceramics image, how i can detect crack surface , pls give me some advice. this my code for detect crack surface
function [img1_array, img2_array,img3_array, img4_array,Zme]= DefectScan(input_path,input_path2);
% clear all;
% close all;
I = imread(input_path2);
J = imread(input_path);
I = rgb2gray(I);
J = rgb2gray(J);
% f=figure,imshow(I);
% g=figure,imshow(J);
hy = fspecial(‘sobel’);
hx = hy’;
Iy = imfilter(double(I), hy, ‘replicate’);
Ix = imfilter(double(I), hx, ‘replicate’);
ey = fspecial(‘sobel’);
fx = ey’;
Jy = imfilter(double(J), ey, ‘replicate’);
Jx = imfilter(double(J), fx, ‘replicate’);
gradmag = sqrt(Ix.^2 + Iy.^2);
gradmag2 = sqrt(Jx.^2 + Jy.^2);
K=figure,imshow(gradmag,[]);
L=figure,imshow(gradmag2,[]);
set(K, ‘visible’,’off’);
set(L, ‘visible’,’off’);
filename = ‘temp_file.jpg’
filename2 = ‘temp_file2.jpg’
saveas(K, filename)
saveas(L, filename2)
i1 = imread(filename)
i2 = imread(filename2)
delete(filename)
delete(filename2)
[x, y, rgb] = ind2sub([size(i1,1) size(i1,2) size(i1,3)], find(i1 ~= 255));
A = i1(min(x):max(x)-1,min(y):max(y)-1,:);
[x, y, rgb] = ind2sub([size(i2,1) size(i2,2) size(i2,3)], find(i2 ~= 255));
B = i2(min(x):max(x)-1,min(y):max(y)-1,:);
A = rgb2gray(A)
B = rgb2gray(B)
I = edge(A,’sobel’)
J = edge(B,’sobel’) I have problem for detection for surface ceramics image, how i can detect crack surface , pls give me some advice. this my code for detect crack surface
function [img1_array, img2_array,img3_array, img4_array,Zme]= DefectScan(input_path,input_path2);
% clear all;
% close all;
I = imread(input_path2);
J = imread(input_path);
I = rgb2gray(I);
J = rgb2gray(J);
% f=figure,imshow(I);
% g=figure,imshow(J);
hy = fspecial(‘sobel’);
hx = hy’;
Iy = imfilter(double(I), hy, ‘replicate’);
Ix = imfilter(double(I), hx, ‘replicate’);
ey = fspecial(‘sobel’);
fx = ey’;
Jy = imfilter(double(J), ey, ‘replicate’);
Jx = imfilter(double(J), fx, ‘replicate’);
gradmag = sqrt(Ix.^2 + Iy.^2);
gradmag2 = sqrt(Jx.^2 + Jy.^2);
K=figure,imshow(gradmag,[]);
L=figure,imshow(gradmag2,[]);
set(K, ‘visible’,’off’);
set(L, ‘visible’,’off’);
filename = ‘temp_file.jpg’
filename2 = ‘temp_file2.jpg’
saveas(K, filename)
saveas(L, filename2)
i1 = imread(filename)
i2 = imread(filename2)
delete(filename)
delete(filename2)
[x, y, rgb] = ind2sub([size(i1,1) size(i1,2) size(i1,3)], find(i1 ~= 255));
A = i1(min(x):max(x)-1,min(y):max(y)-1,:);
[x, y, rgb] = ind2sub([size(i2,1) size(i2,2) size(i2,3)], find(i2 ~= 255));
B = i2(min(x):max(x)-1,min(y):max(y)-1,:);
A = rgb2gray(A)
B = rgb2gray(B)
I = edge(A,’sobel’)
J = edge(B,’sobel’) detection crack surface, doit4me, sendit2me MATLAB Answers — New Questions