could you help fix my code?
17 views (last 30 days)
Show older comments
function varargout = dipfinalproject(varargin)
% DIPFINALPROJECT MATLAB code for dipfinalproject.fig
% DIPFINALPROJECT, by itself, creates a new DIPFINALPROJECT or raises the existing
% singleton*.
%
% H = DIPFINALPROJECT returns the handle to a new DIPFINALPROJECT or the handle to
% the existing singleton*.
%
% DIPFINALPROJECT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DIPFINALPROJECT.M with the given input arguments.
%
% DIPFINALPROJECT('Property','Value',...) creates a new DIPFINALPROJECT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before dipfinalproject_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to dipfinalproject_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 dipfinalproject
% Last Modified by GUIDE v2.5 16-Jan-2023 10:04:45
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @dipfinalproject_OpeningFcn, ...
'gui_OutputFcn', @dipfinalproject_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 dipfinalproject is made visible.
function dipfinalproject_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 dipfinalproject (see VARARGIN)
% Choose default command line output for dipfinalproject
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes dipfinalproject wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = dipfinalproject_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 historgb.
function historgb_Callback(hObject, eventdata, handles)
% hObject handle to historgb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
input=a;
input=rgb2gray(input);
axes(handles.axes3)
imhist(input)
% --- Executes on button press in histogray.
function histogray_Callback(hObject, eventdata, handles)
% hObject handle to histogray (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
input=a;
axes(handles.axes3)
imhist(input)
% --- Executes on button press in complement.
function complement_Callback(hObject, eventdata, handles)
% hObject handle to complement (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
IM2=imcomplement(a);
axes(handles.axes3);
imshow(IM2);
% --- Executes on button press in green.
function green_Callback(hObject, eventdata, handles)
% hObject handle to green (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
green=a;
green(:,:,1)=0;
green(:,:,3)=0;
setappdata(0,'filename',green);
setappdata(0,'imrotation',green);
axes(handles.axes3);
imshow(green)
% --- Executes on button press in Blue.
function Blue_Callback(hObject, eventdata, handles)
% hObject handle to Blue (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
blue=a;
blue(:,:,1)=0;
blue(:,:,2)=0;
setappdata(0,'filename',blue);
setappdata(0,'imrotation',blue);
axes(handles.axes3);
imshow(blue)
% --- Executes on button press in red.
function red_Callback(hObject, eventdata, handles)
% hObject handle to red (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
red=a;
red(:,:,2:3)=0;
setappdata(0,'filename',red);
setappdata(0,'imrotation',red);
axes(handles.axes3);
imshow(red)
% --- Executes on button press in resize.
function resize_Callback(hObject, eventdata, handles)
% hObject handle to resize (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
rz=imresize(a,0.5);
axes(handles.axes3);
imshow(rz)
% --- Executes on button press in equalization.
function equalization_Callback(hObject, eventdata, handles)
% hObject handle to equalization (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
eq=histeq(a);
axes(handles.axes3);
imshow(eq)
% --- Executes on button press in rotate.
function rotate_Callback(hObject, eventdata, handles)
% hObject handle to rotate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
rotate=imrotate(a,45);
axes(handles.axes3);
imshow(rotate);
% --- Executes on button press in gaussian.
function gaussian_Callback(hObject, eventdata, handles)
% hObject handle to gaussian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
noise=imnoise(a,'gaussian');
axes(handles.axes3);
imshow(noise)
% --- Executes on button press in lowpassfilter.
function lowpassfilter_Callback(hObject, eventdata, handles)
% hObject handle to lowpassfilter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
noise=imnoise(a,'salt & pepper');
a3=fspecial('average',[7,7]);
t_sp_a3=filter2(a3,noise);
axes(handles.axes3);
imshow(t_sp_a3/255)
% --- Executes on button press in saltnpepper.
function saltnpepper_Callback(hObject, eventdata, handles)
% hObject handle to saltnpepper (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
noise=imnoise(a,'salt & pepper');
axes(handles.axes3);
imshow(noise)
% --- Executes on button press in flip.
function flip_Callback(hObject, eventdata, handles)
% hObject handle to flip (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
i=getappdata(0,'a');
i2=flipdim(i,2);
axes(handles.axes3);
imshow(i2)
% --- Executes on button press in imageintensity.
function imageintensity_Callback(hObject, eventdata, handles)
% hObject handle to imageintensity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
adjust=imadjust(a);
axes(handles.axes3);
imshow(adjust)
% --- Executes on button press in periodicnoise.
function periodicnoise_Callback(hObject, eventdata, handles)
% hObject handle to periodicnoise (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
s=size(a);
[x,y]=meshgrid(1:s(1),1:s(2));
p=sin(x/3+y/5)+1;
noise=(im2double(a)+p/2)/2;
axes(handles.axes3);
imshow(noise)
% --- Executes on button press in importimage.
function importimage_Callback(hObject, eventdata, handles)
% hObject handle to importimage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=uigetfile();
filename=a;
setappdata(0,'filename',filename);
a=imread(a);
axes(handles.axes1);
imshow(a);
setappdata(0,'a',a)
setappdata(0,'filename',a);
plot(handles.axes1,'a')
% --- Executes on button press in grayshade.
function grayshade_Callback(hObject, eventdata, handles)
% hObject handle to grayshade (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
a_gray=rgb2gray(a);
setappdata(0,'filename',a_gray);
axes(handles.axes3);
imshow(a_gray)
% --- Executes on button press in blacknwhite.
function blacknwhite_Callback(hObject, eventdata, handles)
% hObject handle to blacknwhite (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
a_bw=im2bw(a,.57);
axes(handles.axes3);
imshow(a_bw)
setappdata(0,'filename',a_bw);
% --- Executes on button press in reset.
function reset_Callback(hObject, eventdata, handles)
% hObject handle to reset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=getappdata(0,'a');
imshow(a);
% --- Executes on button press in exit.
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)
msgbox('thanks for using image processing tool')
pause(1)
close();
close();
2 Comments
John D'Errico
on 17 Jan 2023
Since you have not said the slightet amount of what is wrong with your code, I consulted the MATAB crystal ball. But there is some fog. I think it is saying that you may come into a large sum of money. Or maybe you will owe a lot of money. Blasted foggy crystal ball.
So if you want help, then explain what is the problem, as all we see is a large pile of not very easy to read code.
Answers (1)
Walter Roberson
on 17 Jan 2023
Change
a=uigetfile();
filename=a;
to
[a, filepath] = uigetfile();
if ~ischar(a); return; end %user cancel
filename = fullfile(filepath, a);
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!