function varargout = untitled1(varargin)
% UNTITLED1 M-file for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
% singleton*.
%
% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
% the existing singleton*.
%
% UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED1.M with the given input arguments.
%
% UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled1_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 untitled1
% Last Modified by GUIDE v2.5 25-Oct-2009 10:43:24
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled1_OpeningFcn, ...
'gui_OutputFcn', @untitled1_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 untitled1 is made visible.
function untitled1_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 untitled1 (see VARARGIN)
% Choose default command line output for untitled1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled1_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;
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over text1.
function text1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to text1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
global imorg immap immod immmap fr;
[FileName,PathName,FilterIndex]=uigetfile({'*.jpg';'*.tif';'*.png';'*.gif';'*.*'},...
'Open Image',...
'D:\Program Files\MATLAB\R2008a\toolbox\images\imdemos');
if isequal(PathName,0) || isequal(FileName,0)
set(handles.text1,'String','Type path');
else
set(handles.text1,'String',[PathName FileName]);
name1= [PathName FileName];
[imorg,immap,frt]=imread( name1 );
immod=imorg;
immmap=immap;
frt=get_frmt(FilterIndex,FileName);
fr=frt;
% set(handles.orgim,'HandleVisibility','ON');
% axes(handles.orgim);
predraw(handles.orgim,handles.newim);
imshow(immod,immmap);
% axis equal;
% axis tight;
% axis off;
% set(handles.orgim,'HandleVisibility','OFF');
postdraw(handles.orgim);
% set(handles.newim,'HandleVisibility','ON');
% axes(handles.newim);
predraw(handles.newim,handles.orgim);
drawimghist(immmap,immod)
% if isequal(immmap,[])
% if isequal(length(size(immod)),3)
% [cb,b]=imhist(immod(:,:,1));
% [cc,c]=imhist(immod(:,:,2));
% [cd,d]=imhist(immod(:,:,3));
% plot(b,cb,'r',c,cc,'g',d,cd,'b');
% else
% imhist(immod);
% end
% else
% imhist(immod,immmap);
% end
axis tight;
set(handles.newim,'HandleVisibility','OFF');
end
% 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)
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1.
function pushbutton1_ButtonDownFcn(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)
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
%obtains the slider value from the slider component
global imorg immap immod immmap fr prescale imap;
scale = get(handles.slider2,'Value');
%puts the slider value into the edit text component
set(handles.edit5,'String', num2str(scale));
map=immmap;
orim=imorg;
orim = uint8(orim); %Change the orim to be uint8 type.
if ~isequal(map,[])
newim=ind2rgb(orim,map);
rim=imadd(newim,scale);
[immod imap]=rgb2ind(rim,map);
immmap=imap;
else
immod=imadd(orim,scale);
end
%Shown the original image in the orgIm axes
set(handles.newim,'HandleVisibility','OFF');
set(handles.orgim,'HandleVisibility','ON');
axes(handles.orgim);
%imshow(orim/255);
imshow(immod,immmap);
postdraw(handles.orgim);
predraw(handles.newim,handles.orgim);
drawimghist(immmap,immod);
axis tight;
set(handles.newim,'HandleVisibility','OFF');
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider2 (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 slider3_Callback(hObject, eventdata, handles)
% hObject handle to slider3 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
%obtains the slider value from the slider component
global imorg immap immod immmap fr prescale;
scale = get(handles.slider3,'Value');
%puts the slider value into the edit text component
set(handles.edit6,'String', num2str(scale));
orim=imorg;
orim = uint8(orim); %Change the orim to be uint8 type.
if ~isequal(immap,[])
if scale>prescale
ind2rgb(orim);
immod=imadd(orim,scale);
rgb2ind(immod);
else
ind2rgb(orim);
immod=imsubtract(orim,scale);
rgb2ind(immod);
end
else
if scale>prescale
immod=i