D10K-6C01 Pengolahan Citra PCD-ML Pengolahan Citra Menggunakan MATLAB Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran Semester Genap 2015-2016 MATLAB 2015a • Image Processing and Computer Vision – Use graphical tools to visualize and manipulate images and video. Connect to hardware and develop new ideas using libraries of reference-standard algorithms. • Products: – – – – – – – MATLAB Computer Vision System Toolbox Image Acquisition Toolbox Image Processing Toolbox Parallel Computing Toolbox Signal Processing Toolbox Statistics and Machine Learning Toolbox PCD-ML Pengolahan Citra Menggunakan MATLAB Images in Matlab • Matlab is optimised for operating on matrices • Images are matrices! • Many useful built-in functions in the Matlab Image Processing Toolbox • Very easy to write your own image processing functions •3 PCD-ML Pengolahan Citra Menggunakan MATLAB Loading and displaying images >> I=imread('mandrill.bmp','bmp'); % load image Matrix with image data image format as a string image filename as a string >> image(I) % display image >> whos I Name I Size 512x512x3 Bytes Class 786432 uint8 array Grand total is 786432 elements using 786432 bytes Dimensions of I (red, green and blue intensity information) Matlab can only perform arithmetic operations on data with class double! PCD-ML Pengolahan Citra Menggunakan MATLAB Display the left half of the mandrill image Ekstraksi Color Channel %----------membaca dan isi variabel----------------¬ gambar=imread(‘lena.jpg’); red=gambar; green=gambar; blue=gambar; %----------memproses per channel ---------------¬ red(:,:,2)=0; red(:,:,3)=0; green=(:,:,1)=0; green=(:,:,3)=0; blue(:,:,1)=0; blue(:,:,2)=0; %----------menampilkan gambar----------------¬ imshow(gambar) imshow(red) imshow(green) imshow(blue) PCD-ML Pengolahan Citra Menggunakan MATLAB Konversi RGB ke Gray %------- Image Processing Toolbox -----gambar=imread(‘lena.jpg’); gray=rgb2gray(gambar); imshow(gray); %------- Conventional -----gray2 = 0.2989 * rgb(:,:,1) +0.5870 * rgb(:,:,2) + 0.1140 * rgb(:,:,3); imshow(gray2); PCD-ML Pengolahan Citra Menggunakan MATLAB Tipe Image dalam Matlab • Indexed Image • Intensity Image • RGB (truecolor) Image PCD-ML Pengolahan Citra Menggunakan MATLAB Image Complement gambar=imread(‘lena.jpg’); invert=imcomplement(gambar); figure, imshow(invert); Invert/ complement PCD-ML Pengolahan Citra Menggunakan MATLAB Histogram Citra %------- Histogram Seluruh Channel -----gambar=imread(‘lena.jpg’); gray=rgb2gray(gambar); figure,imhist(gray); %------- Histogram Per Channel -----figure, imhist(gambar(:,:,1)); %---Red --figure, imhist(gambar(:,:,2)); %---Green – figure, imhist(gambar(:,:,3)); %---Blue – %Bagaimana kalau imhist(gambar);??? Jelaskan !!! PCD-ML Pengolahan Citra Menggunakan MATLAB Histogram Equalization %------- Histogram Citra -----gambar=imread(‘lena.jpg’); gray=rgb2gray(gambar); figure,imshow(gray),figure,imhist(gray); %------- Histogram Equalization -----gambar=imread(‘lena.jpg’); gray=rgb2gray(gambar); grayeq=histeq(gray); figure,imshow(grayeq),figure,imhist(grayeq ); PCD-ML Pengolahan Citra Menggunakan MATLAB Image Crop %------- Image Crop-----gambar=imread(‘lena.jpg’); crop=imcrop(gambar,[0 0 250 250]); imshow(gambar), figure, imshow(crop); % FORMAT x,y,w,h PCD-ML Pengolahan Citra Menggunakan MATLAB Region of Interest (ROI) • Menandari bagian yang menjadi pusat perhatian (region of interest) • Bentuk area berupa polygon • Format roipoly(I,c,r); • I adalah matriks gambar • c adalah matriks dari kolom ROI • r adalah matriks dari baris ROI PCD-ML Pengolahan Citra Menggunakan MATLAB Contoh Sederhana ROI gambar=imread(‘lena.jpg’); %------- ROI Segi Empat -----c=[0 100 100 0]; r=[0 0 100 100]; ROI=roipoly(gambar,c,r); figure, imshow(ROI); %------- ROI Poligon-----c=[0 100 150 100 0]; r=[0 0 50 100 100]; ROI=roipoly(gambar,c,r); figure, imshow(ROI); %------- Menggunakan fungsi roifill----g=gambar(:,:,1); c=[0 100 150 100 0]; r=[0 0 50 100 100]; ROI=roifill(g,c,r); figure, imshow(ROI); PCD-ML Pengolahan Citra Menggunakan MATLAB Region-based Processing • Define and operate on regions of interest (ROI) • Basic Functions – roipoly – poly2mask mask – regionfill interpolation – roicolor – roifilt2 Specify polygonal region of interest (ROI) Convert region of interest (ROI) polygon to region Fill in specified regions in image using inward Select region of interest (ROI) based on color Filter region of interest (ROI) in image • Interactive Functions – – – – – imellipse imfreehand impoly imrect imroi Create draggable ellipse Create draggable freehand region Create draggable, resizable polygon Create draggable rectangle Region-of-interest (ROI) base class PCD-ML Pengolahan Citra Menggunakan MATLAB Topik Lanjutan • Pengolahan citra pada domain frekuensi – FFT – DCT • Konversi ke Citra Biner • Morphological Image Processing – Dilasi – Erosi • Object counting • Area Proses – Konvolusi – Filtering – Edge Detection • Image Reconstruction • Proses Citra secara Live – Koneksi Kamera – Live histogram PCD-ML Pengolahan Citra Menggunakan MATLAB Image Processing Toolbox • Perform image processing, analysis, and algorithm development • Image Processing Toolbox™ provides a comprehensive set of referencestandard algorithms, functions, and apps for image processing, analysis, visualization, and algorithm development. You can perform image analysis, image segmentation, image enhancement, noise reduction, geometric transformations, and image registration. Many toolbox functions support multicore processors, GPUs, and C-code generation. • Image Processing Toolbox supports a diverse set of image types, including high dynamic range, gigapixel resolution, embedded ICC profile, and tomographic. Visualization functions and apps let you explore images and videos, examine a region of pixels, adjust color and contrast, create contours or histograms, and manipulate regions of interest (ROIs). The toolbox supports workflows for processing, displaying, and navigating large images. PCD-ML Pengolahan Citra Menggunakan MATLAB Capabilities PCD-ML Pengolahan Citra Menggunakan MATLAB Computer Vision Toolbox • Design and simulate computer vision and video processing systems • Computer Vision System Toolbox™ provides algorithms, functions, and apps for the design and simulation of computer vision and video processing systems. You can perform object detection and tracking, feature detection and extraction, feature matching, stereo vision, camera calibration, and motion detection tasks. The system toolbox also provides tools for video processing, including video file I/O, video display, object annotation, drawing graphics, and compositing. Algorithms are available as MATLAB® functions, System objects™, and Simulink® blocks. • For rapid prototyping and embedded system design, the system toolbox supports fixed-point arithmetic and automatic C-code generation. PCD-ML Pengolahan Citra Menggunakan MATLAB Computer Vision Toolbox • • • • • • • • Key Features Feature Detection, Extraction, and Matching Object Detection and Recognition Object Tracking and Motion Estimation Camera Calibration Stereo Vision Video Processing, Display, and Graphics Fixed Point and Code Generation PCD-ML Pengolahan Citra Menggunakan MATLAB Key Features • Object detection, including Viola-Jones and other pretrained detectors • Object tracking, including Kanade-Lucas-Tomasi (KLT) and Kalman filters • Feature detection, extraction, and matching, including FAST, BRISK, MSER, and HOG • Camera calibration for single and stereo cameras, including automatic checkerboard detection and an app for workflow automation • Stereo vision, including rectification, disparity calculation, and 3D reconstruction • Support for C-code generation and fixed-point arithmetic with code generation products • Video processing, object annotation, video file I/O, video display, graphic overlays, and compositing PCD-ML Pengolahan Citra Menggunakan MATLAB Feature Detection and Extraction • A feature is an interesting part of an image, such as a corner, blob, edge, or line. Feature extraction enables you to derive a set of feature vectors, also called descriptors, from a set of detected features. Computer Vision System Toolbox offers capabilities for feature detection and extraction that include: – Corner detection, including Shi & Tomasi, Harris, and FAST methods – BRISK, MSER, and SURF detection for blobs and regions – Extraction of BRISK, FREAK, SURF, and simple pixel neighborhood descriptors – Histogram of Oriented Gradients (HOG) feature extraction – Visualization of feature location, scale, and orientation PCD-ML Pengolahan Citra Menggunakan MATLAB Feature Detection and Extraction PCD-ML Pengolahan Citra Menggunakan MATLAB Videos: Image Processing and Computer Vision Products • Overview – Image Processing Toolbox – Computer Vision Toolbox – Image Acquisition Toolbox – Statistics and Machine Learning Toolbox – Parallel Computing Toolbox PCD-ML Pengolahan Citra Menggunakan MATLAB