Вы находитесь на странице: 1из 11

function varargout = CastroCollo(varargin) %CastroCollo M-file for CastroCollo.

fig % CastroCollo, by itself, creates a new CastroCollo or raises the existing % singleton*. % % H = CastroCollo returns the handle to a new CastroCollo or the handle to % the existing singleton*. % % CastroCollo('Property','Value',...) creates a new CastroCollo using the % given property value pairs. Unrecognized properties are passed via % varargin to CastroCollo_OpeningFcn. This calling syntax produces a % warning when there is an existing singleton*. % % CastroCollo('CALLBACK') and CastroCollo('CALLBACK',hObject,...) call the % local function named CALLBACK in CastroCollo.M with the given input % arguments. % % *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 CastroCollo % Last Modified by GUIDE v2.5 14-Sep-2013 23:24:41 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @CastroCollo_OpeningFcn, ... 'gui_OutputFcn', @CastroCollo_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 CastroCollo is made visible. function CastroCollo_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 %

unrecognized PropertyName/PropertyValue pairs from the command line (see VARARGIN)

% Choose default command line output for CastroCollo handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes CastroCollo wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = CastroCollo_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 pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img if ~isequal(img,0) filtertype = get(handles.popupmenu2, 'value'); axes(handles.axes2); switch(filtertype) case 1 h = fspecial('average'); avrge = imfilter(img,h); imshow(avrge); axes(handles.axes4); hist(avrge(:), 0:255); case 2 h = fspecial('disk'); disssskkk = imfilter(img,h); imshow(disssskkk); axes(handles.axes4); hist(disssskkk(:), 0:255); case 3 h = fspecial('gaussian'); gasn = imfilter(img,h); imshow(gasn); axes(handles.axes4); hist(gasn(:), 0:255); case 4 h = fspecial('laplacian'); lap = imfilter(img,h);

imshow(lap); axes(handles.axes4); hist(lap(:), 0:255); case 5 h = fspecial('log'); lg = imfilter(img,h); imshow(lg); axes(handles.axes4); hist(lg(:), 0:255); case 6 h = fspecial('motion'); mot = imfilter(img,h); imshow(mot); axes(handles.axes4); hist(mot(:), 0:255); case 7 h = fspecial('prewitt'); prw = imfilter(img,h); imshow(prw); axes(handles.axes4); hist(prw(:), 0:255); case 8 h = fspecial('sobel'); sob = imfilter(img,h); imshow(sob); axes(handles.axes4); hist(sob(:), 0:255); case 9 h = fspecial('unsharp'); ushrp = imfilter(img,h); imshow(ushrp); axes(handles.axes4); hist(ushrp(:), 0:255); end end % --- Executes on selection change in popupmenu2. function popupmenu2_Callback(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu2

% --- Executes during object creation, after setting all properties. function popupmenu2_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu 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

% --- Executes on selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1

% --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu 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

% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img global imgmap if ~isequal(img, 0) imgtype = get(handles.popupmenu1,'value'); axes(handles.axes2) switch(imgtype) case 1 imshow(img); axes(handles.axes4); hist(img(:), 0:255); case 2 bin = im2bw(img); imshow(bin); axes(handles.axes4); hist(bin(:), 0:255); case 3 graysc = rgb2gray(img); imshow(graysc); axes(handles.axes4);

hist(graysc(:), 0:255); case 4 case 5 rgb = double(img); if ~isempty(imgmap) rgb = rgb+1; redgreenblue = reshape(cat(3,imgmap(rgb,1),imgmap(rgb,2),imgmap(rgb,3)),size(rgb,1),size(rgb ,2),3); else rgb=rgb/255; end imshow(rgb); axes(handles.axes4); hist(rgb(:), 0:255); end drawnow; end % -------------------------------------------------------------------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 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 Open_Callback(hObject, eventdata, handles) % hObject handle to Open (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img global imgmap [Filename, Pathname] = uigetfile('*.*', 'My Images'); if ischar(Filename) filepath = cat(2, Pathname, Filename); set(handles.text1,'string', filepath); I = fullfile(Pathname, Filename); [img imgmap] = imread(I); axes(handles.axes1); imshow(img); axes(handles.axes3); hist(img(:), 0:255); else img = 0; end

% --- Executes on button press in pushbutton2. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% --- Executes on slider movement. function slider18_Callback(hObject, eventdata, handles) % hObject handle to slider18 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img re = get(handles.slider18, 'Value'); J = img; sz = size(J); K = J;

row = 1; while row <= sz(1) K(row, :, 1) = J(row, :, 1) + 256 * re; row = row + 1; end axes(handles.axes2); imshow(K); axes(handles.axes4); hist(K(:), 0:255); % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties. function slider18_CreateFcn(hObject, eventdata, handles) % hObject handle to slider18 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement. function slider19_Callback(hObject, eventdata, handles) % hObject handle to slider19 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

global img gr = get(handles.slider19, 'Value'); % Returns the position of green slider. J = img; % Gets the image data. sz = size(J); % Gets the size of the image. K = J; % Duplicates the image data for modifications.

row = 1; % initiates the while loop. while row <= sz(1) % Logical condition; only needs the first value of the size. K(row, :, 2) = J(row, :, 2) + 256 * gr; % Indexes the matrix and changes the color accordingly. row = row + 1; % Iterates through the image data. end axes(handles.axes2); imshow(K); axes(handles.axes4); hist(K(:), 0:255); % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties. function slider19_CreateFcn(hObject, eventdata, handles) % hObject handle to slider19 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement. function slider20_Callback(hObject, eventdata, handles) % hObject handle to slider20 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img bl = get(handles.slider20, 'Value'); J = img; sz = size(J); K = J;

row = 1;

while row <= sz(1) K(row, :, 3) = J(row, :, 3) + 256 * bl; row = row + 1; end axes(handles.axes2); imshow(K); axes(handles.axes4); hist(K(:), 0:255); % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties. function slider20_CreateFcn(hObject, eventdata, handles) % hObject handle to slider20 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement. function slider21_Callback(hObject, eventdata, handles) % hObject handle to slider21 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img Gamma = get(handles.slider21, 'Value') + 1; % Returns the position of brightness slider. J = img; K = imadjust(J, [], [], Gamma); % Applies gamma corrections to the image. axes(handles.axes2); imshow(K); axes(handles.axes4); hist(K(:), 0:255); % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties. function slider21_CreateFcn(hObject, eventdata, handles) % hObject handle to slider21 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background.

if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

% --- Executes on slider movement. function slider22_Callback(hObject, eventdata, handles) % hObject handle to slider22 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img T = [get(handles.slider22, 'Value'), 1]; % Returns the position of contrast slider. J = img; K = imadjust(J, stretchlim(J, T), [0 1]); % Changes color saturation limits. axes(handles.axes2); imshow(K); axes(handles.axes4); hist(K(:), 0:255); % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties. function slider22_CreateFcn(hObject, eventdata, handles) % hObject handle to slider22 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end

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

% -------------------------------------------------------------------function MO_Callback(hObject, eventdata, handles) % hObject handle to MO (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img bgi = imopen(img,strel('disk',15)); axes(handles.axes2); imshow(bgi);

axes(handles.axes4); hist(bgi(:), 0:255); % -------------------------------------------------------------------function SoB_Callback(hObject, eventdata, handles) % hObject handle to SoB (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img bgi = imopen(img,strel('disk',15)); I2 = imsubtract(img,bgi); axes(handles.axes2); imshow(I2); axes(handles.axes4); hist(I2(:), 0:255); % -------------------------------------------------------------------function Threshold_Callback(hObject, eventdata, handles) % hObject handle to Threshold (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global img level = graythresh(img); bw = im2bw(img,level); axes(handles.axes2); imshow(bw); axes(handles.axes4); hist(bw(:), 0:255);

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

% --- Executes during object creation, after setting all properties. function axes2_CreateFcn(hObject, eventdata, handles) % hObject handle to axes2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: place code in OpeningFcn to populate axes2

% --- Executes during object deletion, before destroying properties. function axes2_DeleteFcn(hObject, eventdata, handles) % hObject handle to axes2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% --- Executes on mouse press over axes background. function axes2_ButtonDownFcn(hObject, eventdata, handles)

% hObject % eventdata % handles

handle to axes2 (see GCBO) reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA)

% --- Executes during object creation, after setting all properties. function axes1_CreateFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: place code in OpeningFcn to populate axes1

Вам также может понравиться