直接上代码:
%%适用于细长且厚的流挂,边缘有差值 %%划痕缺陷
clc;close all;clear all;
[filename filepath]=uigetfile({'*.jpg';'*.tif';'*.png';'All files (*.*)'},...
'Pick an image file','cc10.jpg');
if isequal(filename,0) || isequal(filepath,0)
msgbox('请先选择一个涂膜缺陷的图片!','Warning');%未选择照片提示
else
image=imread([filepath filename]);
% axes(handles.axes1);
imshow(image);
end
if (~isempty(image))
handles.image=image;
else
return;
end
%第二个axes:
if(~isempty(handles.image))
image=handles.image;
figure(1);imshow(image);
image1=rgb2gray(image);
%axes(handles.axes2);
%imshow(imagegray);
image1=im2double(image1);
figure(2);imshow(image1);
J=1-image1;
%figure(3);imshow(J);
Ih=imhist(image1);Jh=imhist(J); %显示图像image的灰度直方图;
Kh=histeq(J,Ih);%该函数通过直方图均衡化来增加对比度
%figure;imshow(Kh);
seHeight=strel([1 1;1 1],[1 1;1 1]);%