Code covered by the BSD License  

Highlights from
Gamma Adjustment GUI

image thumbnail
from Gamma Adjustment GUI by Eric Johnson
RGBGUI is an interactive gamma adjustment tool for grayscale and RGB (true color) images.

rgbGUI(varargin)
function varargout = rgbGUI(varargin)
% RGBGUI Interactive gamma adjustment tool for images.
%    I = RGBGUI prompts the user to select an image file, then displays an
%    interactive control panel to adjust the gamma of each color channel in the
%    image. If the 'Cancel' button is pressed then RGBGUI returns the original
%    image, otherwise the adjusted image matrix is returned.
%
%    I = RGBGUI(H) attaches to the image plot identified by handle H.
%
%    I = RGBGUI(IMG) uses the image array I.

% Copyright 2010 The MathWorks, Inc.


% Last Modified by GUIDE v2.5 30-Nov-2009 14:27:51

% Begin initialization code - DO NOT EDIT
gui_Singleton = 0;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @rgbGUI_OpeningFcn, ...
                   'gui_OutputFcn',  @rgbGUI_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 rgbGUI is made visible.
function rgbGUI_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 rgbGUI (see VARARGIN)

% Set callbacks
set(handles.bgChannel, 'SelectionChangeFcn',  ...
                       @rgbgui.bgChannelSelect);
set(handles.btnDone,   'Callback',            ...
                       @rgbgui.btnDoneCallback);
set(handles.btnCancel, 'Callback',              ...
                       @rgbgui.btnCancelCallback);
set(handles.fig,       'CloseRequestFcn', ...
                       @rgbgui.figClose   );

% Load data and create image plot if necessary.
[hi,I] = rgbgui.procinput(varargin{:});
handles.hi = hi;
handles.I  = I;

% Gamma point X and Y values
handles.P = {[0 0; 1 1] [0 0; 1 1] [0 0; 1 1]};

% Choose default command line output for rgbGUI
handles.output = I;

% Update handles structure
guidata(hObject, handles);

% Initialize channel controls and gamma plot
rgbgui.setChannels(hObject,[]);

% Position GUI
movegui(handles.fig,'center');

% Close if image is invalid, otherwise wait.
if isempty(I)
    disp('No image selected, exiting RGBGUI.');
    close(handles.fig);
else
    uiwait(handles.fig);
end



% --- Outputs from this function are returned to the command line.
function varargout = rgbGUI_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;
delete(handles.fig);

Contact us