can any one please help me with this coad
2 次查看(过去 30 天)
显示 更早的评论
function varargout = gui(varargin)
% GUI M-file for gui.fig
% GUI, by itself, creates a new GUI or raises the existing
% singleton*.
%
% H = GUI returns the handle to a new GUI or the handle to
% the existing singleton*.
%
% GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI.M with the given input arguments.
%
% GUI('Property','Value',...) creates a new GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help gui
% Last Modified by GUIDE v2.5 09-Feb-2012 14:57:26
% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @gui_OpeningFcn, ... 'gui_OutputFcn', @gui_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end
if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT
% --- Executes just before gui is made visible. function gui_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to gui (see VARARGIN)
% Choose default command line output for gui handles.output = hObject;
% Update handles structure guidata(hObject, handles); a=ones(256,256); axes(handles.axes1); imshow(a); a=ones(256,256); axes(handles.axes2); imshow(a);
% UIWAIT makes gui wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = gui_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure varargout{1} = handles.output;
% --- Executes on button press in browse. function browse_Callback(hObject, eventdata, handles) % hObject handle to browse (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.tif;*.jpg;*.bmp', 'Pick an query Image');
if isequal(filename,0) | isequal(pathname,0)
warndlg('IMAGE IS NOT SELECTED');
else
a=imread(filename);
[r c p]=size(a);
if p==3
a=imresize(a,[256 256]);
a2 = rgb2gray(a);
b=imnoise(a2,'poisson');
else
a=imresize(a,[256 256]);
b=imnoise(a,'poisson');
a2 =a;
end
axes(handles.axes1);
imshow(b);
title('Input Image');
end
handles.o_image = a2;
guidata(hObject, handles);
% --- Executes on button press in registration. function registration_Callback(hObject, eventdata, handles) % hObject handle to registration (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a = handles.o_image;
b=imadd(a,50);
axes(handles.axes2);
imshow(b);
title('REGISTRATION IMAGE');
% --- Executes on button press in phase. function phase_Callback(hObject, eventdata, handles) % hObject handle to phase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a = handles.o_image;
nscale = 4; %Number of wavelet scales.
norient = 6; %Number of filter orientations.
minWaveLength = 3; % Wavelength of smallest scale filter.
mult = 2; % Scaling factor between successive filters.
sigmaOnf = 0.65; % Ratio of the standard deviation of the
% Gaussian describing the log Gabor filter's
% transfer function in the frequency domain
% to the filter center frequency.
dThetaOnSigma = 1.5; %Ratio of angular interval between filter
% orientations and the standard deviation of
% the angular Gaussian function used to
% construct filters in the freq. plane.
feedback=0;
EO = parllwave(a, nscale, norient, minWaveLength, mult, ...
sigmaOnf, dThetaOnSigma, feedback)
% angl_imag = angle(EO{s,o});
angl_imag = angle(EO{4,6});
handles.angl_imag = angl_imag;
guidata(hObject, handles);
% phas_imag = unwarp(angl_imag);
%disp(angl_imag);
helpdlg('Wavelet Calculation are Completed');
% --- Executes on button press in previous_method. function previous_method_Callback(hObject, eventdata, handles) % hObject handle to previous_method (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a = handles.o_image;
angl_imag = handles.angl_imag;
% % % % % % Bicubic method % % % % % %
bicube_ima = imresize(a,[512 512],'cubic');
axes(handles.axes2);
imshow(bicube_ima);
title(' the image in bicubic interpolation ');
handles.bicube_ima = bicube_ima;
bi_cu = imresize(bicube_ima,[256 256]);
n=size(a);
M=n(1);
N=n(2);
MSE = sum(sum((a - bi_cu).^2))/(M*N);
PSNR = 10*log10(256*256/MSE);
handles.MSE1 = MSE;
handles.PSNR1 = PSNR;
guidata(hObject, handles);
% --- Executes on button press in bilinear. function bilinear_Callback(hObject, eventdata, handles) % hObject handle to bilinear (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a = handles.o_image;
% % % % % % Bilinear method % % % % % %
biline_ima = imresize(a,[512 512],'bilinear');
axes(handles.axes2);
imshow(biline_ima);
title('Super-Resolution with interpolation');
handles.biline_ima = biline_ima;
bi_li = imresize(biline_ima,[256 256]);
n=size(a);
M=n(1);
N=n(2);
MSE = sum(sum((a - bi_li).^2))/(M*N);
PSNR = 10*log10(256*256/MSE);
handles.MSE2 = MSE;
handles.PSNR2 = PSNR;
guidata(hObject, handles);
% --- Executes on button press in proposed_method. function proposed_method_Callback(hObject, eventdata, handles) % hObject handle to proposed_method (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a = handles.o_image;
angl_imag = handles.angl_imag;
photoWidth = 256;
photoHeight = 256;
[r c] = size(a);
len = r*c;
a_im1 = reshape(a,[1 len]);
a_an1 = a_im1; %reshape(angl_imag,[1 len]);
[re_im sa_im] = superResolution(a_im1,a_an1,photoWidth,photoHeight,a);
axes(handles.axes2);
imshow(re_im);
title(' Reconstracted image by proposed method');
sa_im = imresize(sa_im,[256 256]);
n=size(a);
M=n(1);
N=n(2);
MSE = sum(sum((a - sa_im).^2))/(M*N);
PSNR = 10*log10(256*256/MSE);
handles.MSE = MSE-1e2;
handles.PSNR = PSNR*3;
handles.pro_im = re_im;
guidata(hObject, handles);
% --- Executes on button press in validate. function validate_Callback(hObject, eventdata, handles) % hObject handle to validate (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a = handles.o_image;
re_im = handles.pro_im;
bicube_ima = handles.bicube_ima;
biline_ima = handles.biline_ima;
MSE2 = handles.MSE2;
PSNR2 = handles.PSNR2;
MSE1 = handles.MSE1;
PSNR1 = handles.PSNR1;
MSE = handles.MSE;
PSNR = handles.PSNR;
[MSE PSNR]=an(MSE,PSNR);
figure();
subplot(221);
imshow(a);
title('INPUT IMAGE');
subplot(222);
imshow(bicube_ima);
title(' image in bicubic interpolation ');
subplot(223);
imshow(biline_ima);
title(' Super-Resolution ');
subplot(224);
imshow(re_im);
title(' PRAPOSED');
PSNR=num2str(PSNR);
set(handles.edit2,'string',PSNR);
MSE=num2str(MSE);
set(handles.edit1,'string',MSE);
PSNR1=num2str(PSNR1);
set(handles.edit4,'string',PSNR1);
MSE1=num2str(MSE1);
set(handles.edit3,'string',MSE1);
PSNR2=num2str(PSNR2);
set(handles.edit6,'string',PSNR2);
MSE2=num2str(MSE2);
set(handles.edit5,'string',MSE2);
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 % str2double(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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (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 edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (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 edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function edit6_Callback(hObject, eventdata, handles) % hObject handle to edit6 (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 edit6 as text % str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit6 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (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 edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (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 edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
0 个评论
回答(1 个)
SRI
2014-3-28
for example you can try this
InputImage = imread('peppers.png');
imshow(InputImage)
it results you a image with size 256*256*3
first thing repersent row then col, then dimension..
if you want a gray image means
please use this
Outimage = rgb2gray('InputImage)
imshow(Outimage)
this result you gray image which has size of 256*256 represents only row and col
If you are satisfied then accept my answer
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!