?? mydip.asv
字號:
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.axes2);
imshow(extendx,[]);
handles.imdata=x;
guidata(hObject, handles);
% --------------------------------------------------------------------
function LogT_Callback(hObject, eventdata, handles)
% hObject handle to LogT (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);
mode.WindowStyle='modal';
mode.Interpreter='tex';
msgbox('g(x,y)=a+(ln[f(x,y)+1])/(b*ln(c))','the formul','mode');
prompt={'parameter a:' 'parameter b:' 'parameter c:'};
name='Input for LOG tranformation';
numlines=1;
defaultanswer={'0' '1' '10'};
anss=inputdlg(prompt,name,numlines,defaultanswer);
a=str2num(anss{1});
b=str2num(anss{2});
c=str2num(anss{3});
f1=double(f);
N=256;
g=a*ones([row,col])+log(f1+ones([row,col]))/(b*log(c));
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 ExpT_Callback(hObject, eventdata, handles)
% hObject handle to ExpT (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;
f1=double(f);
[row,col]=size(f);
mode.WindowStyle='modal';
mode.Interpreter='tex';
msgbox('g(x,y)=b^(c*[f(x,y)-a])','the formula','mode');
prompt={'parameter a:' 'parametr b:' 'parameter c:'};
name='Input for Exp tranformation';
numlines=1;
defaultanswer={'0' '2' '0.04'};
anss=inputdlg(prompt,name,numlines,defaultanswer);
a=str2num(anss{1});
b=str2num(anss{2});
c=str2num(anss{3});
N=256;
g=b.^(c*(f1-a*ones([row,col])))-1;
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 Untitled_28_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_28 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_27_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_27 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_26_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_26 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_29_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_29 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_30_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_30 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_31_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_31 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_32_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_32 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_33_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_33 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_34_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_34 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_35_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_35 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_36_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_36 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_37_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_37 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_38_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_38 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% st2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --------------------------------------------------------------------
function MovingNoise_Callback(hObject, eventdata, handles)
% hObject handle to MovingNoise (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);
handles.source=x;
f=double(x);
prompt={'Distance(0~255):' 'Angle(-180~180):'};
name='Input for movement blurring';
numlines=1;
defaultanswer={'30' '0'};
anss=inputdlg(prompt,name,numlines,defaultanswer);
len=str2num(anss{1});
angle=str2num(anss{2});
mPSF=fspecial('motion',len,angle);
y=imfilter(f,mPSF,'circular','conv');
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.P=mPSF;
handles.blurred=y;
handles.inverseblurred=y;
handles.flag=logical(0);
handles.imdata=y;
guidata(hObject, handles);
% --------------------------------------------------------------------
function MovingPlusnoise_Callback(hObject, eventdata, handles)
% hObject handle to MovingPlusRandomnoise (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);
f=x;
prompt={'Distance(0~255):' 'Angle(-180~180):'};
name='Input for movement blurring with noise';
numlines=1;
defaultanswer={'30' '0'};
anss=inputdlg(prompt,name,numlines,defaultanswer);
len=str2num(anss{1});
angle=str2num(anss{2});
mPSF=fspecial('motion',len,angle);
y=imfilter(f,mPSF,'circular','conv');
noise=imnoise(zeros(size(y)),'gaussian',0,0.1);
noiseadded=imadd(y,im2uint8(noise));
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)=noiseadded(m,n);
else
extendx(m,n)=realmax;
end
end
end
axes(handles.axes2);
imshow(extendx,[min(min(y)),max(max(y))]);
handles.P=mPSF;
handles.noi=noise;
handles.blurred=noiseadded;
handles.inverseblurred=y;
handles.flag=logical(1);
handles.imdata=y;
guidata(hObject, handles);
% --------------------------------------------------------------------
function InverseFilter_Callback(hObject, eventdata, handles)
% hObject handle to InverseFilter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handls nduee)
tic;
g=handles.blurred;
[row,col]=size(g);
PSF=handles.P;
y=deconvwnr(g,PSF);
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 WinnerFilter_Callback(hObject, eventdata, handles)
% hObject handle to WinnerFilter (see GCBO)
% eventdata reerved - to be defined in a future version of MALAB
% handles structure with handles and user data (see GUIDATA)
tic;
blurred=handles.inverseblurred;
g=handles.blurred;
[row,col]=size(g);
f=handles.source;
PSF=handles.P;
if handles.flag==logical(0)
y=deconvwnr(g,PSF);
else
noise=handles.noi;
NP=abs(fft2(noise)).^2;
ncorr=fftshift(real(ifft2(NP)));
IP=abs(fft2(im2double(blurred))).^2;
icorr=fftshift(real(ifft2(IP)));
y=deconvwnr(g,PSF,ncorr,icorr);
handes.flag=logical(0);
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 Untitled_40_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_40 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_45_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_45 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_43_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_43 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_42_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_42 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_46_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_46 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_47_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_47 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_48_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_48 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_44_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_44 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Gradient_Callback(hObject, eventdata, handles)
% hObject handle to Gradient (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);
prompt={'Threshold:'};
name='Input for Gradient Sharping';
numlines=1;
defaultanswer={'10'};
anss=inputdlg(prompt,name,numlines,defaultanswer);
th=str2num(anss{1});
f1=double(f);
f2=zeros(row,col);
for x=2:(row-1)
for y=2:(col-1)
g=abs(f1(x,y)-f1(x+1,y))+abs(f1(x,y)-f1(x,y+1));
if g>=th
f2(x,y)=g;
else
f2(x,y)=f1(x,y);
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -