Model Ruang Warna Pengolahan Citra
Dalam bidang pengolahan citra digital dikenal berbagai macam ruang warna (color space) citra.
Yang paling umum adalah ruang warna RGB (Red, Green, Blue).
Ruang warna RGB mendefinisikan suatu warna berdasarkan tiga kanal (channel) warna yaitu merah, hijau, dan biru.
Ruang warna RGB untuk citra truecolor 24 bit diilustrasikan oleh gambar berikut:
Ruang warna yang kedua yaitu ruang warna HSV (Hue, Saturation, Value).
Hue merupakan suatu nilai yang merepresentasikan spektrum warna dari cahaya tampak (merah, jingga, kuning, hijau, biru, dan ungu).
Saturation merupakan nilai yang menunjukkan tingkat kejenuhan atau kemurnian dari suatu warna. Semakin besar nilai saturasi maka semakin murni warna yang dihasilkan.
Sedangkan value dapat didefinisikan sebagai nilai yang menunjukkan tingkat kecerahan warna.
Ruang warna HSV diperoleh dari ruang warna RGB melalui persamaan berikut:
Ruang warna HSV diilustrasikan pada gambar di bawah ini:
Ruang warna yang ketiga yaitu ruang warna NSTC atau YIQ terdiri dari luminance (Y) dan chrominance (I dan Q).
Persamaan yang digunakan untuk mengkonversi ruang warna RGB menjadi NTSC adalah:
Ruang warna NTSC diilustrasikan pada gambar berikut:
Ruang warna yang keempat adalah ruang warna YCbCr yang terdiri dari luminance (Y) dan chrominance (Cb dan Cr).
Persamaan yang digunakan untuk mengkonversi ruang warna RGB menjadi ruang warna YCbCr adalah:
Sedangkan ilustrasi ruang warna YCbCr ditunjukkan pada gambar berikut:
Berikut ini merupakan contoh aplikasi pemrograman GUI Matlab untuk mengkonversi ruang warna citra RGB menjadi ruang warna yang lain.
Tahapan-tahapannya antara lain:
2. Menampilkan citra RGB beserta masing-masing kanal dan histogramnya
3. Menampilkan citra HSV beserta masing-masing kanal dan histogramnya
4. Menampilkan citra NTSC beserta masing-masing kanal dan histogramnya
5. Menampilkan citra YCbCr beserta masing-masing kanal dan histogramnya
File source code lengkap beserta citra untuk mengkonversi ruang warna citra dapat diperoleh melalui halaman berikut ini: Source Code
Sedangkan tampilan koding matlab nya yaitu:
function varargout = Color_Conversion(varargin) % COLOR_CONVERSION MATLAB code for Color_Conversion.fig % COLOR_CONVERSION, by itself, creates a new COLOR_CONVERSION or raises the existing % singleton*. % % H = COLOR_CONVERSION returns the handle to a new COLOR_CONVERSION or the handle to % the existing singleton*. % % COLOR_CONVERSION('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in COLOR_CONVERSION.M with the given input arguments. % % COLOR_CONVERSION('Property','Value',...) creates a new COLOR_CONVERSION or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before Color_Conversion_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Color_Conversion_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 Color_Conversion % Last Modified by GUIDE v2.5 08-Jun-2016 13:51:22 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Color_Conversion_OpeningFcn, ... 'gui_OutputFcn', @Color_Conversion_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 Color_Conversion is made visible. function Color_Conversion_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 Color_Conversion (see VARARGIN) % Choose default command line output for Color_Conversion handles.output = hObject; % Update handles structure guidata(hObject, handles); movegui(hObject,'center'); % UIWAIT makes Color_Conversion wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = Color_Conversion_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; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(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) [filename, pathname] = uigetfile({'*.*'}); if ~isequal(filename,0) Img = imread(fullfile(pathname,filename)); info = imfinfo(fullfile(pathname,filename)); bitdepth = info.BitDepth; if bitdepth ==24 axes(handles.axes1) imshow(Img) set(handles.popupmenu1,'enable','on') set(handles.popupmenu1,'Value',1) else errordlg('Image must be RGB','File Error'); end else return end handles.Img = Img; guidata(hObject, handles); % --- Executes on selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (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 popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1 Img = handles.Img; val = get(hObject,'Value'); switch val case 1 axes(handles.axes1) imshow(Img) R = Img(:,:,1); axes(handles.axes2) imshow(R) axes(handles.axes5) imhist(R) G = Img(:,:,2); axes(handles.axes3) imshow(G) axes(handles.axes6) imhist(G) B = Img(:,:,3); axes(handles.axes4) imshow(B) axes(handles.axes7) imhist(B) case 2 HSV = rgb2hsv(Img); axes(handles.axes1) imshow(HSV) H = HSV(:,:,1); axes(handles.axes2) imshow(H) axes(handles.axes5) imhist(H) S = HSV(:,:,2); axes(handles.axes3) imshow(S) axes(handles.axes6) imhist(S) V = HSV(:,:,3); axes(handles.axes4) imshow(V) axes(handles.axes7) imhist(V) case 3 NTSC = rgb2ntsc(Img); axes(handles.axes1) imshow(NTSC) Y = NTSC(:,:,1); axes(handles.axes2) imshow(Y) axes(handles.axes5) imhist(Y) I = NTSC(:,:,2); axes(handles.axes3) imshow(I) axes(handles.axes6) imhist(I) Q = NTSC(:,:,3); axes(handles.axes4) imshow(Q) axes(handles.axes7) imhist(Q) case 4 YCbCr = rgb2ycbcr(Img); axes(handles.axes1) imshow(YCbCr) Y = YCbCr(:,:,1); axes(handles.axes2) imshow(Y) axes(handles.axes5) imhist(Y) Cb = YCbCr(:,:,2); axes(handles.axes3) imshow(Cb) axes(handles.axes6) imhist(Cb) Cr = YCbCr(:,:,3); axes(handles.axes4) imshow(Cr) axes(handles.axes7) imhist(Cr) end % --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu1 (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
Posted on June 8, 2016, in Pengolahan Citra and tagged aplikasi pengolahan citra dengan matlab, aplikasi pengolahan citra digital menggunakan matlab, aplikasi pengolahan citra menggunakan matlab, citra dan histogram, citra RGB, citra truecolor, contoh matlab, contoh program matlab, contoh program matlab pengolahan citra, contoh program matlab sederhana, contoh program pengolahan citra digital menggunakan matlab, gui matlab, image processing, Model Ruang Warna Pengolahan Citra, pemrograman gui matlab, pengenalan matlab, pengolahan citra dengan matlab, Pengolahan Citra Digital, pengolahan citra digital dan aplikasinya menggunakan matlab, pengolahan citra digital dengan matlab, pengolahan citra digital menggunakan matlab, program matlab sederhana, ruang warna citra nstc, ruang warna citra ycbcr, ruang warna hsv, Ruang warna RGB matlab, source code matlab pengolahan citra, source code program matlab pengolahan citra sederhana, transformasi ruang warna citra, tutorial matlab untuk pengolahan citra. Bookmark the permalink. 7 Comments.
kang, maksud di line 176, 179, 181 dan 186 itu apa ya ?
itu matriks kah ?
Yang penting code ini aja kan ya kang :
“YCbCr = rgb2ycbcr(Img);”
untuk merubah suatu gambar dr RGB ke YCbCr ?
line 176 untuk mengambil komponen Y
line 181 untuk mengambil komponen Cb
line 186 untuk mengambil komponen Cr
mas maksud dari MAX(r,g,b) itu apa ya ?
nilai maximal dari r g b ?
jika nilai r=200 g=100 dan b=10
maka nilai max nya ada 200 ?
apa benar ?
benar rahmani seperti itu
mas maksud dari MAX(r,g,b) itu apa ya ?
nilai maximal dari r g b ?
jika nilai r=200 g=100 dan b=10
maka nilai max nya ada 200 ?
apa benar ?
benar seperti itu