⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mydip.asv

📁 《数字图像处理与分析》光盘使用说明 本光盘主要包括两部分内容: 1、 作者编制的基于MATLAB和基于VC++实现的数字图像处理软件
💻 ASV
📖 第 1 页 / 共 5 页
字号:
    end
end
Time=toc;
set(handles.edit1,'string',Time);
extendx=double(zeros(256));
if (row<=256)&(row<=256)
    W=256;
else
    W=max(row,col);
end
for m=1:W
     for n=1:W
          if (m<=row)&(n<=col)
          extendx(m,n)=f2(m,n);
          else
              extendx(m,n)=realmax;
          end
     end
end
axes(handles.axes2);
imshow(extendx,[min(min(f2)),max(max(f2))]);
handles.imdata=f2;
guidata(hObject, handles);

% --------------------------------------------------------------------
function Prewitt_Callback(hObject, eventdata, handles)
% hObject    handle to Prewitt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
tic;
f=handles.imdata;
[row,col]=size(f);
f1=edge(f,'prewitt');
Time=toc;
set(handles.edit1,'string',Time);
extendx=double(zeros(256));
if (row<=256)&(row<=256)
    W=256;
else
    W=max(row,col);
end
for m=1:W
     for n=1:W
          if (m<=row)&(n<=col)
          extendx(m,n)=f1(m,n);
          else
              extendx(m,n)=1;
          end
     end
end
axes(handles.axes2),imshow(extendx);
handles.imdata=f1;
guidata(hObject, handles);

% --------------------------------------------------------------------
function GrayThreshold_Callback(hObject, eventdata, handles)
% hObject    andle to GrayThreshold (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
tic;
x=handles.imdata;
N=256;
[row,col]=size(x);
th=0;
p=zeros(N);
for i=1:row*col
       p(fix(x(i)+1))=p(fix(x(i)+1))+1;
end

p1=zeros(N);
p1(1)=p(1);
for i=2:N
    p1(i)=p(i)-p(i-1);
end
p2=zeros(N);
p2(1)=p1(1);
for i=2:N
    p2(i)=p1(i)-p1(i-1);
end
for i=1:N
    if p2(i)>=0
        th=p2(i);
    end
end

for i=1:row*col;
    if x(i)>th
        x(i)=256;
    else
        x(i)=0;
    end 
end
Time=toc;
set(handles.edit1,'string',Time);

if (row<=256)&(row<=256)
    W=256;
else
    W=max(row,col);
end
extendx=double(zeros(W));
for m=1:W
     for n=1:W
          if (m<=row)&(n<=col)
          extendx(m,n)=x(m,n);
          else
              extendx(m,n)=realmax;
          end
     end
end
axes(handles.axes2);
imshow(extendx,[0,255]);
msgbox('If the result is not satisfying,there maybe more than two peak values in the Histogram? ','Help','help');
handles.imdata=x;
guidata(hObject, handles);

% --------------------------------------------------------------------
function Untitled_51_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_51 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_49_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_49 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)




% --------------------------------------------------------------------
function ImageMove_Callback(hObject, eventdata, handles)
% hObject    handle to ImageMove (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
tic;
x=handles.imdata;
[row,col]=size(x);
prompt={'pixels of horizontal displacement:' 'pixels of vertical displacement:'};
name='Input for Geometric Transformation';
numlines=1;
defaultanswer={'50' '50'};
anss=inputdlg(prompt,name,numlines,defaultanswer);
x0=str2num(anss{1});
y0=str2num(anss{2});
T=[1 0 0;0 1 0;x0 y0 1];
tform=maketform('affine',T);
g=imtransform(x,tform,'XData',[1 col],'YData',[1 row],'FillValue',0.5);
Time=toc;
set(handles.edit1,'string',Time);
if (row<=256)&(row<=256)
    W=256;
else
    W=max(row,col);
end
extendx=double(zeros([W,W]));
for m=1:W
     for n=1:W
          if (m<=row)&(n<=col)
          extendx(m,n)=g(m,n);
          else
              extendx(m,n)=realmax;
          end
     end
end
axes(handles.axes2);
imshow(extendx,[min(min(g)),max(max(g))]);
handles.imdata=g;
guidata(hObject, handles);

% --------------------------------------------
function HorizontalTransform_Callback(hObject, eventdata, handles)
% hObject    handle to HorizontalTransform (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
tic;
x=handles.imdata;
[row,col]=size(x);
for i=1:row
    for j=1:col
        y(i,j)=x(i,col-j+1);
    end
end
Time=toc;
set(handles.edit1,'string',Time);
if (row<=256)&(row<=256)
    W=256;
else
    W=max(row,col);
end
extendx=double(zeros([W,W]));
for m=1:W
     for n=1:W
          if (m<=row)&(n<=col)
          extendx(m,n)=y(m,n);
          else
              extendx(m,n)=realmax;
          end
     end
end
axes(handles.axes2);
imshow(extendx,[min(min(y)),max(max(y))]);
handles.imdata=y;
guidata(hObject, handles);

% --------------------------------------------------------------------
function ImageTranspose_Callback(hObject, eventdata, handles)
% hObject    handle to ImageTranspose (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
tic;
x=handles.imdata;
[row,col]=size(x);
for i=1:col
    for j=1:row
        y(i,j)=x(j,i);
    end
end
Time=toc;
set(handles.edit1,'string',Time);
if (row<=256)&(row<=256)
    W=256;
else
    W=max(row,col);
end
extendx=double(zeros([W,W]));
for m=1:W
     for n=1:W
          if (m<=col)&(n<=row)
          extendx(m,n)=y(m,n);
          else
              extendx(m,n)=realmax;
          end
     end
end
axes(handles.axes2);
imshow(extendx,[min(min(y)),max(max(y))]);
handles.imdata=y;
guidata(hObject, handles);

% --------------------------------------------------------------------
function ImageZoom_Callback(hObject, eventdata, handles)
% hObject    handle to ImageZoom (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
tic;
x=handles.imdata;
[row,col]=size(x);
prompt={'zoom proportion for horizon(positive fraction or integer):' 'zoom proportion for vertical(positive fraction or integer):'};
name='Input for Geometric Transformation';
numlines=1;
defaultanswer={'0.5' '0.5'};
anss=inputdlg(prompt,name,numlines,defaultanswer);
Xratio=str2num(anss{1});
Yratio=str2num(anss{2});
T=[Xratio 0 0;0 Yratio 0;0 0 1];
tform=maketform('affine',T);
g=imtransform(x,tform);
Time=toc;
set(handles.edit1,'string',Time);
[row,col]=size(g);
if (row<=256)&(col<=256)
    for m=1:256
         for n=1:256
              if (m<=row)&(n<=col)
              extendx(m,n)=g(m,n);
              else
                  extendx(m,n)=realmax;
              end
         end
    end
    axes(handles.axes2);
    imshow(extendx,[]);
else
    M=max(row,col);
    for m=1:M
         for n=1:M
              if (m<=row)&(n<=col)
              extendx(m,n)=g(m,n);
              else
                  extendx(m,n)=realmax;
              end
         end
    end
    axes(handles.axes2);
    imshow(extendx,[]);
    msgbox('The output image has a width or height larger than 256!','HELP','help');
end
handles.imdata=g;
guidata(hObject, handles);

% --------------------------------------------------------------------
function ImageRotate_Callback(hObject, eventdata, handles)
% hObject    handle to ImageRotate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
tic;
x=handles.imdata;
prompt={'Angle(-360~360):'};
name='Input for Geometric Transformation';
numlines=1;
defaultanswer={'45'};
anss=inputdlg(prompt,name,numlines,defaultanswer);
theta=str2num(anss{1});
T=[cos(theta) sin(theta) 0;-sin(theta) cos(theta) 0;0 0 1];
tform=maketform('affine',T);
g=imtransform(x,tform);
Time=toc;
set(handles.edit1,'string',Time);
[row,col]=size(g);
if (row<=256)&(col<=256)
    for m=1:256
         for n=1:256
              if (m<=row)&(n<=col)
              extendx(m,n)=g(m,n);
              else
                  extendx(m,n)=realmax;
              end
         end
    end
    axes(handles.axes2);
    imshow(extendx,[]);
else
    M=max(row,col);
    for m=1:M
         for n=1:M
              if (m<=row)&(n<=col)
              extendx(m,n)=g(m,n);
              else
                  extendx(m,n)=realmax;
              end
         end
    end
    axes(handles.axes2);
    imshow(extendx,[]);
    msgbox('The output image has a width or height larger than 256!','HELP','help');
end
handles.imdata=g;
guidata(hObject, handles);

% --------------------------------------------------------------------
function VerticalTransform_Callback(hObject, eventdata, handles)
% hObject    handle to VerticalTransform (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
tic;
x=handles.imdata;
[M,N]=size(x);
for i=1:M
    for j=1:N
        y(i,j)=x(M-i+1,j);
    end
end
Time=toc;
set(handles.edit1,'string',Time);
if (M<=256)&(N<=256)
    W=256;
else
    W=max(M,N);
end
extendx=double(zeros([W,W]));
for m=1:W
     for n=1:W
          if (m<=M)&(n<=N)
          extendx(m,n)=y(m,n);
          else
              extendx(m,n)=realmax;
          end
     end
end
axes(handles.axes2);
imshow(extendx,[min(min(y)),max(max(y))]);
handles.imdata=y;
guidata(hObject, handles);

% --------------------------------------------------------------------
function CloseFile_Callback(hObject, eventdata, handles)
% hObject    handle to CloseFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
x=zeros(256);
axes(handles.axes1);
imshow(x);
axes(handles.axes2);
imshow(x);
set(handles.edit1,'string',0.0);
guidata(hObject, handles);

% --------------------------------------------------------------------
function EXIT_Callback(hObject, eventdata, handles)
% hObject    handle to EXIT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;

% --------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
% hObject    handle to file (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_52_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_52 (see GCBO)
% evntdaa  rserved-to e dene in  fur veio f MTLAB
%handle   structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function ReloadRecentImage_Callback(hObject, eventdata, handles)
% hObject    handle to ReloadRecentImage (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
x=handles.reload;
[row,col,Cnums]=size(x);
axes(handles.axes2);
imshow(zeros([256,256]));
if Cnums==1
    if (row<=256)&(col<=256)
        W=256;
    else
        W=max(row,col);
    end
    for m=1:W
        for n=1:W
              if (m<=row)&(n<=col)
              extendx(m,n)=x(m,n);
              else
                  extendx(m,n)=realmax;
              end
         end
    end
axes(handles.axes1);
Imshow(extendx);
else
    if (row<=256)&(col<=256)
        W=256;
    else
        W=max(row,col);
    end
    for m=1:W
         for n=1:W
              if (m<=row)&(n<=col)
              extendx(m,n,:)=x(m,n,:);
              else
                  extendx(m,n,:)=realmax;
              end
         end
    end
    axes(handles.axes1);
    Imshow(extendx);
    msgbox('Please transform it to a monochrome image or it can not be processed correctly','fileopening','warning');
end
title('recent image reloaded!');
handles.imdata=handles.reload;
guidata(hObject, handles);


% --------------------------------------------------------------------
function SaveResult_Callback(hObject, eventdata, handles)
% hObject    handle to SaveResult (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile({'*.bmp';'*.jpg';'*.jpeg'}, 'Pick an image-file');
    if isequal(filename,0) | isequal(pathname,0)
       disp('User pressed cancel')
    else
       disp(['User selected ', fullfile(pathname, filename)])

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -