You are on page 1of 21

Introduction to the Project The project entitled Image Processing using MATLAB is a software base simulator that allows

the user to process the image in different manner. MATLAB software contains Image Processing Toolbox that provides a comprehensive set of reference-standard algorithms, functions, and apps for image processing, analysis, visualization, and algorithm development. You can perform image enhancement, image deblurring, feature detection, noise reduction, image segmentation, geometric transformations, and image registration. Many toolbox functions are multithreaded to take advantage of multicore and multiprocessor computers. Image Processing Toolbox supports a diverse set of image types, including high dynamic range, gigapixel resolution, embedded ICC profile, and tomographic. Visualization functions let you explore an image, examine a region of pixels, adjust the contrast, create contours or histograms, and manipulate regions of interest (ROIs). With toolbox algorithms you can restore degraded images, detect and measure features, analyze shapes and textures, and adjust color balance. The project uses the m.file function of the MATLAB for easy programming of different features of the said project. An m-file, or script file, is a simple text file where you can place MATLAB commands. When the file is run, MATLAB reads the

commands and executes them exactly as it would if you had typed each command sequentially at the MATLAB prompt. All m-file names must end with the extension '.m' (e.g. test.m). If you create a new m-file with the same name as an existing mfile, MATLAB will choose the one which appears first in the path order.Using mfile will benefit the creator of the program because it will process your request at the MATLAB prompt fast and efficient. However, as the number of commands increases or trial and error is done by changing certain variables or values, typing the commands over and over at the MATLAB prompt becomes tedious. M-files will be helpful and almost necessary in these cases. Graphical User Interface(GUI) was also introduced in making this project easier to use.GUI provides point-and-click control of software applications, eliminating the need to learn a language or type commands in order to run the application.

Acknowledgement: We, the Jess Enrique G. Cruz and Philip Cueto would like to thank God for giving us the ability to accomplish the task given to us by Engr. Valiente. We would like also to thank our professor, Engr. Leonardo Valiente Jr., for giving us an idea and a group project that enables us to design an Image Processing using MATLAB and; for teaching us the principles regarding MATLAB Simulink software and Programming using M-File command. It serves as our main foundation for making this project possible. We would like also to thank our family and friends for there never ending support. Also mathworks.com for providing us the software (MATLAB). I would like also to express my gratitude on the Laboratory Assistant in Open Laboratory(N302) for letting us to use the room for our major setting in making the project.

Philip Cueto Jess Enrique Cruz

Program Description This project aims to simulate and process image using different image processing techniques. The program will retrieve the stored image signal. The stored image signal must be Read Write and Display the image. This can be done by applying the Graphical User Interface. The image will be process in different forms such as Binary image, Image type, Indexed Image, intensity Image, Multiframm image, RGB (Red,green and Blue) image. Other function of this Software is that it is capable of applying FIR filters in the given image. The image will be filter according to the preference of the user. Morphological opening is a image enhancement technique that I pursues the goals of removing the numerous imperfections of binary images by accounting for the form and structure of the image. These techniques can be extended to greyscale images. Another user define function that is considered is that the subtraction of background. Subtraction of background is another image enhancement technique. Subtraction of background is necessary for the next procedure which is Image contrast adjustment. It creates more uniform background.

After the subtraction of background, the image has a uniform background but is now a bit too dark. Image contrast must be done in order to adjust the darkness or lightness of the image. The project starts by choosing an image by clicking the Choose Image button that lets you choose any image that will be going to process. After choosing the image, it will be display in the first axes. This image can be filter using different filter enhancing technique that is located in the Image Characteristic Menu, you can choose FREELY what filter characteristic. You can choose to default the program by clicking the button Restore that will restore the original image to its original Form. A button devoted to Close that will terminate the running program.

Scope and Limitation The limitation of project is that it can only process a single image. The process image also outputs single processed image. This software can only process one image at a time. For application, the Software can only be run if the computer or device has a MATLAB. This project can only run and test in the MATLAB software alone. It cannot be publish in other format as well. Another limitation of this project is that the image must be in jpg format alone. Upon Running the program, some image that contains much pixels rate will experience slow process of filtering the signal. Also, the limit of this software is that some version of MATLAB does not support GUI

Screen Capture of Image File

M- FILE OF THE PROJECT

function varargout = ECE107L_Group4projectedit(varargin) %ECE107L_GROUP4PROJECTEDIT M-file for ECE107L_Group4projectedit.fig % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help ECE107L_Group4projectedit % Last Modified by GUIDE v2.5 16-Sep-2013 10:51:09 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @DSP_Project_OpeningFcn, ... 'gui_OutputFcn', @DSP_Project_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 DSP_Project is made visible. function DSP_Project_OpeningFcn(hObject, ~, 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 DSP_Project (see VARARGIN) % Choose default command line output for DSP_Project handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes DSP_Project wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = DSP_Project_OutputFcn(~, ~, 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 select_pushbutton1. function CHOOSEIMAGE_pushbutton1_Callback(hObject, ~, handles) [Filename, Pathname] = uigetfile('*.*', 'Choose an image'); % Open standard dialog box for retrieving files CI = fullfile(Pathname, Filename); %appends the file path and the filename together IMG = imread(CI); %Read image from graphics file image(IMG); %this displays the image handles.Pic = IMG; %creates the handle for the image to be modified. axes(handles.axes4) imshow (IMG); %Display image guidata(hObject, handles); %Store or retrieve GUI data %update the handles structure % hObject handle to select_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 button press in exit_pushbutton2. function CLOSE_pushbutton2_Callback(~, ~, ~) close % hObject handle to exit_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 RED_slider1_Callback(hObject, ~, handles) RD = get(hObject, 'Value'); J = handles.Pic; SZE = size(J); K = J;

row = 1; while row <= SZE(1) K(row, :, 1) = J(row, :, 1) + 256 * RD; row = row + 1; end axes(handles.axes1)

imshow(K); %Display image guidata(hObject, handles); %Store or retrieve GUI data % hObject handle to red_slider1 (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

% --- Executes during object creation, after setting all properties. function RED_slider1_CreateFcn(hObject, ~, ~) usewhitebg = 1; if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackground')); end % hObject handle to red_slider1 (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 multi background.

% --- Executes on slider movement. function GREEN_slider2_Callback(hObject, ~, handles) GRN = get(hObject, 'Value'); J = handles.Pic; SZE = size(J); K = J;

row = 1; while row <= SZE(1) K(row, :, 2) = J(row, :, 2) + 256 * GRN; row = row + 1; end axes(handles.axes1) imshow(K); %Display image guidata(hObject, handles); %Store or retrieve GUI data % hObject handle to green_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

% --- Executes during object creation, after setting all properties. function GREEN_slider2_CreateFcn(hObject, ~, ~)

usewhitebg = 1; if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]); else set(hObject,'BackgoundColor',get(0,'defaultUicontrolBackgroundColor')); end % hObject handle to green_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 multi background.

% --- Executes on slider movement. function BLUE_slider3_Callback(hObject, ~, handles) BLE = get(hObject, 'Value'); J = handles.Pic; SZE = size(J); K =J;

row = 1; while row <= SZE(1) K(row, :, 3) = J(row, :, 3) + 256 * BLE; row = row + 1; end axes(handles.axes1) imshow(K); %Display image guidata(hObject, handles); %Store or retrieve GUI data % hObject handle to blue_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

% --- Executes during object creation, after setting all properties. function BLUE_slider3_CreateFcn(hObject, ~, ~) usewhitebg = 1; if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]); else set(hObject,'BackgoundColor',get(0,'defaultUicontrolBackgroundColor')); end % hObject handle to blue_slider3 (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 multi background.

% --- Executes on slider movement. function BRIGHTNESS_slider4_Callback(hObject, ~, handles) GA = get(hObject, 'Value') + 1; J = handles.Pic; K = imadjust(J, [], [], GA); %Adjust image intensity values or colormap imshow(K); guidata(hObject, handles); %Store or retrieve GUI data % hObject handle to brightness_slider4 (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

% --- Executes during object creation, after setting all properties. function BRIGHTNESS_slider4_CreateFcn(hObject, eventdata, handles) usewhitebg = 1; if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]); else set(hObject,'BackgoundColor',get(0,'defaultUicontrolBackgroundColor')); end % hObject handle to brightness_slider4 (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 multi background.

% --- Executes on slider movement. function CONTRAST_slider5_Callback(hObject, eventdata, handles) T = [get(hObject, 'Value'), 1]; J = handles.Pic; K = imadjust(J, stretchlim(J, T), [0 1]); %Find limits to contrast stretch image axes(handles.axes1) imshow(K); %Display image guidata(hObject, handles); %Store or retrieve GUI data % hObject handle to contrast_slider5 (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

% --- Executes during object creation, after setting all properties. function CONTRAST_slider5_CreateFcn(hObject, eventdata, handles) whitebg = 1; if whitebg; set(hObject,'BackgroundColor',[.9 .9 .9]); else

set(hObject,'BackgoundColor',get(0,'defaultUicontrolBackgroundColor')); end % hObject handle to contrast_slider5 (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 multi background.

% --- Executes on button press in restore_pushbutton3. function RESTORE_pushbutton3_Callback(hObject, eventdata, handles) RESTRE = get(hObject, 'Value'); A = handles.Pic; K = A; axes(handles.axes1) imshow(K); % hObject handle to restore_pushbutton3 (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 binary_pushbutton4. function BINARY_pushbutton4_Callback(hObject, eventdata, handles) BINRY = get(hObject, 'Value'); H = handles.Pic; K = H; BI = im2bw(K,0.4); %Convert image to binary image, based on threshold axes(handles.axes1) imshow(BI); % hObject handle to binary_pushbutton4 (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 thresh_pushbutton5. function THRESHOLD_pushbutton5_Callback(hObject, eventdata, handles) MOR = get(hObject, 'Value'); RP = handles.Pic; K = RP; background = imopen(K,strel('disk',10)); %Morphologically open image %Create morphological structuring element (STREL) M = K - background; BW1 = im2bw(M); BW2 = bwareaopen(BW1, 50); axes(handles.axes1) imshow(BW2) %Display image % hObject handle to thresh_pushbutton5 (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 morpho_pushbutton6. function MORPHOLOGICAL_pushbutton6_Callback(hObject, eventdata, handles) MOR = get(hObject, 'Value'); RP = handles.Pic;

K = RP; BCKGRND = imopen(K,strel('disk',10)); %Morphologically open image axes(handles.axes1) imshow(BCKGRND); %Display image % hObject handle to morpho_pushbutton6 (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 FIR_pushbutton7. function FIR_pushbutton7_Callback(hObject, eventdata, handles) F = get(hObject, 'Value'); R = handles.Pic; K = R; T = ones(5,5)/25; F = imfilter(R,T); %N-D filtering of multidimensional images axes(handles.axes1) imshow(F); %Display image % hObject handle to FIR_pushbutton7 (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 SUBTRACT_pushbutton8. function SUBTRACT_pushbutton8_Callback(hObject, eventdata, handles) MOR = get(hObject, 'Value'); RP = handles.Pic; K = RP; BCKGRND = imopen(K,strel('disk',15)); %Estimate and subtract the background of an image I = K - BCKGRND; axes(handles.axes1) imshow(I); %Display image % hObject handle to SUBTRACT_pushbutton8 (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 INDEXED_pushbutton9. function INDEXED_pushbutton9_Callback(hObject, eventdata, handles) F = get(hObject, 'Value'); R = handles.Pic; K = R; [X,MAP]=rgb2ind(K,32); %Convert RGB image to indexed image axes(handles.axes1) imshow(X,MAP); %Display image % hObject handle to INDEXED_pushbutton9 (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 MRI_pushbutton10. %function MRI_pushbutton10_Callback(hObject, eventdata, handles) %MRI = uint8(zeros(128,128,1,27)); %for frame=1:27

% [MRI(:,:,:,frame),map] = imread('mri.tif',frame); %end %montage(MRI,map); %MOV = immovie(MRI,map); %Make movie from multiframe image %movie(MOV) % hObject handle to MRI_pushbutton10 (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 GRAYSCALE_pushbutton11. function GRAYSCALE_pushbutton11_Callback(hObject, eventdata, handles) F = get(hObject, 'Value'); R = handles.Pic; K = R; J = rgb2gray(K); %Convert RGB image or colormap to grayscale axes(handles.axes1) imshow(J); % hObject handle to GRAYSCALE_pushbutton11 (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 slider6_CreateFcn(hObject, eventdata, handles) % hObject handle to slider6 (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 slider7_Callback(hObject, eventdata, handles) % hObject handle to slider7 (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

% --- Executes during object creation, after setting all properties. function slider7_CreateFcn(hObject, eventdata, handles) % hObject handle to slider7 (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 slider8_Callback(hObject, eventdata, handles) % hObject handle to slider8 (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

% --- Executes during object creation, after setting all properties. function slider8_CreateFcn(hObject, eventdata, handles) % hObject handle to slider8 (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 slider9_Callback(hObject, eventdata, handles) % hObject handle to slider9 (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

% --- Executes during object creation, after setting all properties. function slider9_CreateFcn(hObject, eventdata, handles) % hObject handle to slider9 (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 slider10_Callback(hObject, eventdata, handles) % hObject handle to slider10 (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

% --- Executes during object creation, after setting all properties. function slider10_CreateFcn(hObject, eventdata, handles) % hObject handle to slider10 (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

THREE SAMPLE OUTPUT BINARY FILTERING

RGB FILTERING ( Dominant RED)

Morphological Filtering

References: Nick Efford. Digital Image Processing: A Practical Introduction Using JavaTM. Pearson Education, 2000. http://www.cs.auckland.ac.nz/courses/compsci773s1c/lectures/ImageProcessinghtml/topic4.htm http://www.mathworks.com

You might also like