Code covered by the BSD License  

Highlights from
Image Enhancer

image thumbnail

Image Enhancer

by

 

A simple GUI image editing application which is able to compress images and apply effects to them.

IEeffects(varargin)
function varargout = IEeffects(varargin)
% GUI_EFFECTS MATLAB code for IEeffects.fig
%      GUI_EFFECTS, by itself, creates a new GUI_EFFECTS or raises the existing
%      singleton*.
%
%      H = GUI_EFFECTS returns the handle to a new GUI_EFFECTS or the handle to
%      the existing singleton*.
%
%      GUI_EFFECTS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_EFFECTS.M with the given input arguments.
%
%      GUI_EFFECTS('Property','Value',...) creates a new GUI_EFFECTS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before IEeffects_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to IEeffects_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 IEeffects

% Last Modified by GUIDE v2.5 16-Jul-2013 20:54:05

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

% Choose default command line output for IEeffects
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% Variables
global I;

% Display image
axes(handles.imgEffects); cla(handles.imgEffects);
image(I);
set(gca,'XTick',[],'YTick',[],'DataAspectRatio',[1 1 1]);

% UIWAIT makes IEeffects wait for user response (see UIRESUME)
uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = IEeffects_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)


% --- Executes on selection change in listMaps.
function listMaps_Callback(hObject, eventdata, handles)
% hObject    handle to listMaps (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns listMaps contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listMaps

global M; global I; M = I;

if get(handles.listMaps,'Value') ~= 1
    Y = 0.299*M(:,:,1) + 0.587*M(:,:,2) + 0.114*M(:,:,3);
    Y = cat(3,Y,Y,Y);

    x = linspace(0,255,64);

    maps = cellstr(get(handles.listMaps,'String'));
    map = eval(lower(maps{get(handles.listMaps,'Value')}));
    
    Yr = interp1(x,map(:,1),double(Y(:,:,1)));
    Yg = interp1(x,map(:,2),double(Y(:,:,2)));
    Yb = interp1(x,map(:,3),double(Y(:,:,3)));

    M = Yr;
    M(:,:,2) = Yg;
    M(:,:,3) = Yb;
    
    M = uint8(M.*255);
end

axes(handles.imgEffects); cla(handles.imgEffects);
image(M);
set(gca,'XTick',[],'YTick',[],'DataAspectRatio',[1 1 1]);

% --- Executes during object creation, after setting all properties.
function listMaps_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listMaps (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 blackWhite.
function blackWhite_Callback(hObject, eventdata, handles)
% hObject    handle to blackWhite (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global I; global M; M = I;
Y = 0.299*M(:,:,1) + 0.587*M(:,:,2) + 0.114*M(:,:,3);

f1 = find(Y >= 128); Y(f1) = 255;
f2  = find(Y < 255); Y(f2) = 0;
M = cat(3,Y,Y,Y);

axes(handles.imgEffects); cla(handles.imgEffects);
image(M);
set(gca,'XTick',[],'YTick',[],'DataAspectRatio',[1 1 1]);


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

global I; global M; M = I;

% Change contrast +60
Mr = M(:,:,1);
Mg = M(:,:,2);
Mb = M(:,:,3);

x = [0 94 98 255];
y = [0 34 158 255];

M(:,:,1) = floor(interp1(x, y, double(Mr), 'spline')); % MCr
M(:,:,2) = floor(interp1(x, y, double(Mg), 'spline')); % MCg
M(:,:,3) = floor(interp1(x, y, double(Mb), 'spline')); % MCb

% Change exposure +30
M = M + 30;

% Display image
axes(handles.imgEffects); cla(handles.imgEffects);
image(M);
set(gca,'XTick',[],'YTick',[],'DataAspectRatio',[1 1 1]);

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

global I; global M; M = I;

% Change contrast +15
Mr = M(:,:,1);
Mg = M(:,:,2);
Mb = M(:,:,3);

x = [0 71.5 120.5 255];
y = [0 56.5 135.5 255];

M(:,:,1) = floor(interp1(x, y, double(Mr), 'spline')); % MCr
M(:,:,2) = floor(interp1(x, y, double(Mg), 'spline')); % MCg
M(:,:,3) = floor(interp1(x, y, double(Mb), 'spline')); % MCb

% Change exposure +25
M = M + 25;

% Display image
axes(handles.imgEffects); cla(handles.imgEffects);
image(M);
set(gca,'XTick',[],'YTick',[],'DataAspectRatio',[1 1 1]);


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

global I; global M; M = I;
Y = 0.299*M(:,:,1) + 0.587*M(:,:,2) + 0.114*M(:,:,3);
M = cat(3,Y,Y,Y);

axes(handles.imgEffects); cla(handles.imgEffects);
image(M);
set(gca,'XTick',[],'YTick',[],'DataAspectRatio',[1 1 1]);


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

global I; global M; I = M;

uiresume(handles.figure1);
delete(handles.figure1);


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

delete(handles.figure1);


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

% Reset variables
global I; global M; M = I;

% Reset image
axes(handles.imgEffects); cla(handles.imgEffects);
image(I);
set(gca,'XTick',[],'YTick',[],'DataAspectRatio',[1 1 1]);

Contact us