matlab图像缺陷检测识别系统DIY
从预处理到最终输出可视化效果展示
clc;close all;clear all;
[filename filepath]=uigetfile({'*.jpg';'*.tif';'*.png';'All files (*.*)'},...
'Pick an image file','C:\Users\57281\Desktop\可执行文件.EXE\缺陷照片收集\(grain)\RGB');
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);
%T = imread ('bat.png');%读入图像
%M = imresize ( T ,[256 ,256 ]);%将图像调整256 ×256 ,为了显示方便
YT = rgb2gray(image);%将RGB 格式转换为灰度图像
%axes(handles.axes2);
%imshow(image1),title("灰度化",'Color','r','FontSize',20);
figure , imshow( YT) ;
tit