【图像处理】gabor提取织物表面特征值进行织物瑕疵识别和处理
程序员文章站
2024-03-09 14:05:53
...
clear all;
clc;
RGB = imread('normalpic.jpg');
L=rgb2gray(RGB);
% figure,imshow(L)
[G,gabout1] = gaborfilter2(L,11,11,0.25,1*pi/3);%对图像进行gabor滤波
% figure,imshow(uint8(gabout1))
h = fspecial('gaussian',[3,3],11)
I2=imfilter(gabout1,h);
%figure,imshow(uint8(I2))
f_max=(3/4)*max(I2(:));
f_min=(1/8)*min(I2(:));
M = imread('hole.jpg');
R=rgb2gray(M);
subplot(2,3,1)
imshow(R);title('待检图像')
[G,gabout] = gaborfilter2(R,11,11,0.25,1*pi/3);%对图像进行gabor滤波
subplot(2,3,3)
imshow(uint8(gabout));title('Gabor滤波图像');
g = fspecial('gaussian',[3,3],11)
I3=uint8(imfilter(gabout,g));
subplot(2,3,5)
imshow(I3);title('高斯平滑图像');
[a,b] = size(I3);
for i = 1:a;
for j = 1:b;
if I3(i,j)<f_max & I3(i,j)>f_min
I3(i,j) = 0;
else
I3(i,j) = 255;
end
end
end
B=[0 1 0;1 1 1;0 1 1];
I4=imdilate(I3,B);
C=[0 1 0;1 1 1;0 1 1];
I5=imdilate(I4,C);
se = strel('ball',7,5);
I6 = imerode(I5,se);
subplot(2,3,6)
imshow(I6);title('最终结果');
subplot(2,3,2)
imhist(R);title('原图直方图');
subplot(2,3,4)
imhist(uint8(gabout));title('Gabor滤波直方图');
%subplot(2,2,3)
%imhist(I3);title('高斯平滑直方图');
%subplot(2,2,4)
%imhist(I5);title('结果直方图');
往期回顾>>>>>>
完整代码添加QQ1575304183
下一篇: 使用jdbc连接数据库