FInal Docu DSP
-
Upload
philip-cueto -
Category
Documents
-
view
219 -
download
0
Transcript of FInal Docu DSP
-
8/13/2019 FInal Docu DSP
1/21
-
8/13/2019 FInal Docu DSP
2/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
-
8/13/2019 FInal Docu DSP
3/21
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 m-
file, MATLAB will choose the one which appears first in the path order.Using m-
file 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.
-
8/13/2019 FInal Docu DSP
4/21
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
-
8/13/2019 FInal Docu DSP
5/21
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.
-
8/13/2019 FInal Docu DSP
6/21
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.
-
8/13/2019 FInal Docu DSP
7/21
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
-
8/13/2019 FInal Docu DSP
8/21
Screen Capture of Image File
-
8/13/2019 FInal Docu DSP
9/21
M- FILE OF THE PROJECT
functionvarargout = 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 helpECE107L_Group4projectedit
% Last Modified by GUIDE v2.5 16-Sep-2013 10:51:09
% Begin initialization code - DO NOT EDITgui_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', []);
ifnargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});
end
ifnargout[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.functionDSP_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_Projecthandles.output = hObject;
% Update handles structureguidata(hObject, handles);% UIWAIT makes DSP_Project wait for user response (see UIRESUME)% uiwait(handles.figure1);
-
8/13/2019 FInal Docu DSP
10/21
% --- Outputs from this function are returned to the command line.functionvarargout = 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 structurevarargout{1} = handles.output;
% --- Executes on button press in select_pushbutton1.functionCHOOSEIMAGE_pushbutton1_Callback(hObject, ~, handles)[Filename, Pathname] = uigetfile('*.*', 'Choose an image');% Open standard dialog box for retrieving filesCI = fullfile(Pathname, Filename);%appends the file path and the filename togetherIMG = imread(CI);%Read image from graphics fileimage(IMG);
%this displays the imagehandles.Pic = IMG;%creates the handle for the image to be modified.axes(handles.axes4)imshow (IMG); %Display imageguidata(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.functionCLOSE_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.functionRED_slider1_Callback(hObject, ~, handles)RD = get(hObject, 'Value');J = handles.Pic;SZE = size(J);K = J;
row = 1;whilerow
-
8/13/2019 FInal Docu DSP
11/21
imshow(K); %Display imageguidata(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 ofslider
% --- Executes during object creation, after setting all properties.functionRED_slider1_CreateFcn(hObject, ~, ~)usewhitebg = 1;ifusewhitebg
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.functionGREEN_slider2_Callback(hObject, ~, handles)GRN = get(hObject, 'Value');J = handles.Pic;SZE = size(J);K = J;
row = 1;whilerow
-
8/13/2019 FInal Docu DSP
12/21
usewhitebg = 1;ifusewhitebg
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.functionBLUE_slider3_Callback(hObject, ~, handles)BLE = get(hObject, 'Value');J = handles.Pic;SZE = size(J);K =J;
row = 1;whilerow
-
8/13/2019 FInal Docu DSP
13/21
% --- Executes on slider movement.functionBRIGHTNESS_slider4_Callback(hObject, ~, handles)GA = get(hObject, 'Value') + 1;J = handles.Pic;K = imadjust(J, [], [], GA); %Adjust image intensity values or colormapimshow(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 ofslider
% --- Executes during object creation, after setting all properties.functionBRIGHTNESS_slider4_CreateFcn(hObject, eventdata, handles)usewhitebg = 1;ifusewhitebg
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.
functionCONTRAST_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 stretchimageaxes(handles.axes1)imshow(K); %Display imageguidata(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 ofslider
% --- Executes during object creation, after setting all properties.functionCONTRAST_slider5_CreateFcn(hObject, eventdata, handles)whitebg = 1;ifwhitebg;
set(hObject,'BackgroundColor',[.9 .9 .9]);else
-
8/13/2019 FInal Docu DSP
14/21
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.functionRESTORE_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.functionBINARY_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 thresholdaxes(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.functionTHRESHOLD_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.functionMORPHOLOGICAL_pushbutton6_Callback(hObject, eventdata, handles)MOR = get(hObject, 'Value');RP = handles.Pic;
-
8/13/2019 FInal Docu DSP
15/21
K = RP;BCKGRND = imopen(K,strel('disk',10)); %Morphologically open imageaxes(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.functionFIR_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 imagesaxes(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.functionSUBTRACT_pushbutton8_Callback(hObject, eventdata, handles)MOR = get(hObject, 'Value');RP = handles.Pic;K = RP;BCKGRND = imopen(K,strel('disk',15)); %Estimate and subtract the backgroundof an imageI = 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.functionINDEXED_pushbutton9_Callback(hObject, eventdata, handles)F = get(hObject, 'Value');R = handles.Pic;K = R;[X,MAP]=rgb2ind(K,32); %Convert RGB image to indexed imageaxes(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
-
8/13/2019 FInal Docu DSP
16/21
% [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.functionGRAYSCALE_pushbutton11_Callback(hObject, eventdata, handles)F = get(hObject, 'Value');R = handles.Pic;K = R;J = rgb2gray(K); %Convert RGB image or colormap to grayscaleaxes(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.functionslider6_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.
ifisequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);end
% --- Executes on slider movement.functionslider7_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 ofslider
% --- Executes during object creation, after setting all properties.functionslider7_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
-
8/13/2019 FInal Docu DSP
17/21
-
8/13/2019 FInal Docu DSP
18/21
% --- Executes on slider movement.functionslider10_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 ofslider
% --- Executes during object creation, after setting all properties.functionslider10_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.ifisequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);end
-
8/13/2019 FInal Docu DSP
19/21
THREE SAMPLE OUTPUT
BINARY FILTERING
RGB FILTERING ( Dominant RED)
-
8/13/2019 FInal Docu DSP
20/21
Morphological Filtering
-
8/13/2019 FInal Docu DSP
21/21