Anda di halaman 1dari 23

https://azatutama.wordpress.

com/pengolahan-citra/

Pengolahan Citra
Sesi 1
Computer Graphics
adalah proses untuk menciptakan suatu gambar berasarkan deskripsi objek maupun latar belakang yang
terkandung pada gambar tersebut.
Merupakan teknik untuk membuat gambar objek sesuai dengan obyek tersebut di alam nyata (realism).
Computer Vision
merupakan proses mnyusun deskripsi tentang obyek yang terkandung pada suatu gambar atu mengenali
objek yang ada pada gambar;
Pengenalan pola (Pattern Recognition): Speech Recognition;
Kecerdasan Buatan (artificial intelegi): specch understanding
IMAGE PROCESSING :
Memperbaiki kualitas gambar:
aspek radiometrik: peningkatan kontras , transformasi warna, restorasi citra.
aspek geometrik:rotasi, translasi, skala, transformasi
Melakukan pemilihan citra ciri *feature images) yang optimal utk tujuan analisis
Melakukan penarikan proses informasi atau deskripsi obyek atau pengenalan obyek yg terkandung pada
citra
Melakukan kompresi atau reduksi data untuk tujuan penyimpanan data, transmisi data, dan waktu proses
data
Aplikasi Pengolahan Citra:
kedokteran gigi orthondonti)
kedokteran biomedik
penginderaan jarak jauh/inderaja (remote sensing)
industri
bahasa isyarat
pengenalan karakter
Tugas 1
Convert image to binary via Matlab:
>> a = imread( Sorrento.jpg )

hasilnya:
>> whos

(jadi hasilnya Red = 960, Green = 1280, Blue = 3 total=3686400 bytes maka 3686400/1024=3600 KB
terus 3600/1024=3,51 MB)
>> a(1,1,:)

hasilnya:

(red=(:,:,1)=18 green=(:,:,2)=33 blue=(:,:,3)=38)


>> figure, imshow(a)

hasilnya:

>> a_gray = rgb2gray (a);


>> figure, imshow(a_gray);

hasilnya:

>> figure, imhist (a_gray)

hasilnya:

>> subplot (1,2,1), imshow (a_gray)


>> subplot (1,2,2), imhist (a_gray)

hasilnya:

Kode-kode :

>> a = imread(Nama image.jpg)

>> whos

>> a(1,1,:)

>> a_gray = rgb2gray(a);

>> figure, imshow(a)

>> figure, imhist(a_gray)

>> subplot (1,2,1), imshow(a_gray)


>> subplot (1,2,2), imhist(a_gray)
extra

>> figure, imshow(a_red)

>> figure, imshow(a_green)

>> figure, imshow(a_blue)

>> figure, imhist(a_red)

>> figure, imhist(a_green)

>> figure, imhist(a_blue)


Thats all Thank you and my best regards
Sesi 2
1. Digital Image Processing (ke biner & RGB)
Apa itu digital image processing?
Image atau gambar adalah representasi spasial dari suatu objek yang sebenarnya dalam bidang dua
dimensi yang biasanya ditulis dalam koordinat kartesian x-y, dan setiap koordinat merepresentasikan satu
sinyal terkecil dari objek yang biasanya koordinat terkecil ini disebut sebagai piksel. Karena merupakan
sistem koordinat yang memiliki nilai maka biasanya image dianggap sebagai sebuah matrik x-y yang berisi
nilai piksel.
Represntasi dari matriks tersebut dapat ditulis sebagai berikut:

Dan di MATLAB representasi ini biasa ditulis menjadi

Yang perlu diperhatikan adalah bahwa indeks matriks pada MATLAB selalu dimulai dengan anggak 1
sehingga untuk f(0,0) akan sama dengan f(1,1) pada matlab. Bentuk matrik ini kemudian diolah menurut
teori-teori tertentu yang bertujuan untuk memecahkan masalah tertentu, bentuk matriks adalah perwujudan
dari bentuk sinyal digital sehingga proses pemecahan dan pengolahan matriks dari gambar ini biasanya
disebut dengan digital image processing.

Pembacaan Image
Pada matlab fungsi untuk melakukan pembacaan image standar yaitu:
imread(filename)
ilustrasinya sebagai berikut :

Hasil dari pembacaan imread(filename) bisa berupa matriks dua dimensi jika gambar yang dibaca
adalah gambar grayscale dan matrik 3 dimensi jika berupa gambar 3 dimensi.
Membedakan hasil RGB
red=gambar(:,:,1) %memanggil matriks gambar yang hanya berisi piksel warna merah
green=gambar(:,:,2) %memanggil matriks gambar yang hanya berisi piksel warna hijau
blue=gambar(:,:,3) %memanggil matriks gambar yang hanya berisi piksel warna biru
%-menampilkan
imshow(red)
imshow(green)
imshow(blue)

Keterangan dari kiri kekanan : red,green , blue


2. Menampilkan Histogram
imhist(red)
imhist(green)
imhist(blue)

gambarimshow(gambar)

3. Menghitung Depth resolution


Sebelum menghitung depth resolution , sebaiknya file gambar kita convet dahulu ke format .bmp agar lebih
mudah menghitungnya.
Untuk melihat rincian file gambarnya bisa dilihat di:
Klik kanan file>Properties>Details
Sesuai rincian file yang saya jadikan sampel berikut adalah cara penghitungannya
24 Bit Image :
1680 x 1050 = 1764000
File Size
1764000 x 3 = 5292000 bytes
Dalam Bentuk KB:
5292000 / 1024 = 5168 KB
5268 / 1024 = 5,14 MB
Sesi 3
KORELASI dan KONVOLUSI
Korelasi adalah operasi yang digunakan dalam berbagai aplikasi dalam bidang pengolahan isyarat secara
digital. Korelasi merupakan ukuran derajat kesamaan antara dua isyarat atau sekuens. Jika diketahui x[n]
dan y[n] dengan energi yang terbatas maka kros-korelasi antara x[n] dan y[n]
Konvolusi adalah salah satu proses filtering image yang sering dilakukan pada proses pengolahan gambar.
Pada MATLAB terdapat banyak sekali cara yang dapat dilakukan untuk melakukan proses konvolusi. Proses
konvolusi dilakukan dengan menggunakan matriks yang biasa disebut mask yaitu matriks yang berjalan
sepanjang proses dan digunakan untuk menghitung nilai representasi lokal dari beberapa piksel pada image
Contoh:

Karena gambar mobil berwarna hitam putih , maka hasil binerisasi citra nya kurang lebih akan berbentuk
angka 0 dan 255 dalam arti
0 = nilai warna hitam
255 = nilai warna putih
Untuk penghitungannya kita ambil contoh 9 angka pada array pixel berikut ini
0

255

255

*
255

-1

-1

-1

-1

-1

-1

-1

-1

Dengan rumus

e = (8*0)+(-1*0)+(-1*0)+(-1*0)+(-1*0)+(-1*0)+(-1*255)+(-1*255)+(-1*255)
e = (0) +

(0) + (0) + (0) + (0) + (0) + (-255) + (-255) + (-255)

e = 765
Thank you. Thats all
Tugas 2

Gambar ini saya


akan di filter

nama ga
mbar: ferari.jpg
dulu kita konvert ke binner
Hasilnya:

terus kita coba filter konvulusi:

hasilnya:

Thats all. Thank you and my best regards.


Tugas 4
Morphological ImagePprocessing
Image Processing Morphological functions. We can use these functions to perform common image processing
tasks, such as contrast enhancement, noise removal, thinning, skeletonization, filling, and segmentation.
Morphology Fundamentals: Dilation and Erosion
Morphology is a broad set of image processing operations that process images based on shapes.
Morphological operations apply a structuring element to an input image, creating an output image of the
same size. In a morphological operation, the value of each pixel in the output image is based on a
comparison of the corresponding pixel in the input image with its neighbors. By choosing the size and shape
of the neighborhood, you can construct a morphological operation that is sensitive to specific shapes in the
input image.
This table lists the rules for both dilation and erosion.

Opera

Rule

Dilation The value of the output pixel is the maximum value of all the pixels in the input
pixels neighborhood. In a binary image, if any of the pixels is set to the value 1, the
output pixel is set to 1.
Erosion The value of the output pixel is the minimum value of all the pixels in the input pixels

Opera

Rule
neighborhood. In a binary image, if any of the pixels is set to 0, the output pixel is set
to 0.

Morphological Dilation of a Binary Image

The following figure illustrates this processing for a grayscale image. The figure shows the processing of a
particular pixel in the input image. Note how the function applies the rule to the input pixels neighborhood
and uses the highest value of all the pixels in the neighborhood as the value of the corresponding pixel in the
output image.
Morphological Dilation of a Grayscale Image

The Origin of a Structuring Element


The morphological functions use this code to get the coordinates of the origin of structuring elements of any
size and dimension.
origin = floor((size(nhood)+1)/2)
(In this code nhood is the neighborhood defining the structuring element. Because structuring elements are
MATLAB objects, you cannot use the size of the STREL object itself in this calculation. You must use
the STREL getnhood method to retrieve the neighborhood of the structuring element from
the STREL object. For information about other STREL object methods, )
For example, the following illustrates a diamond-shaped structuring element.
Origin of a Diamond-Shaped Structuring Element

Creating a Structuring Element


The toolbox dilation and erosion functions accept structuring element objects, called STRELs. You use
the strel function to create STRELs of any arbitrary size and shape. The strel function also includes
built-in support for many common shapes, such as lines, diamonds, disks, periodic lines, and balls.

Note You typically choose a structuring element the same size and shape as the objects you
want to process in the input image. For example, to find lines in an image, create a linear
structuring element.
For example, this code creates a flat, diamond-shaped structuring element.
se = strel('diamond',3)
se =

Flat STREL object containing 25 neighbors.


Decomposition: 3 STREL objects containing a total of 13 neighbors

Neighborhood:
0

Dilating an Image
To dilate an image, use the imdilate function. The imdilate function accepts two primary arguments:

The input image to be processed (grayscale, binary, or packed binary image)


A structuring element object, returned by the strel function, or a binary matrix defining the
neighborhood of a structuring element
This example dilates a simple binary image containing one rectangular object.
BW = zeros(9,10);
BW(4:6,4:7) = 1
BW =
0

To expand all sides of the foreground component, the example uses a 3-by-3 square structuring element
object.
SE = strel('square',3)
SE =

Flat STREL object containing 3 neighbors.

Neighborhood:
1

To dilate the image, pass the image BW and the structuring element SE to the imdilatefunction. Note how
dilation adds a rank of 1s to all sides of the foreground object.
BW2 = imdilate(BW,SE)

Eroding an Image
To erode an image, use the imerode function. The imerode function accepts two primary arguments:

The input image to be processed (grayscale, binary, or packed binary image)


A structuring element object, returned by the strel function, or a binary matrix defining the
neighborhood of a structuring element

imerode also accepts three optional arguments: SHAPE, PACKOPT, and M.


The SHAPE argument affects the size of the output image. The PACKOPT argument identifies the input
image as packed binary. If the image is packed binary, M identifies the number of rows in the original image.
(Packing is a method of compressing binary images that can speed up the processing of the image.)
The following example erodes the binary image circbw.tif:
1.

Read the image into the MATLAB workspace.


BW1 = imread('circbw.tif');

2.

Create a structuring element. The following code creates a diagonal structuring element object.

3.

SE = strel('arbitrary',eye(5));

4.

SE=

5.
6.
7.

Flat STREL object containing 5 neighbors.

8.

Neighborhood:

9.

10.

11.

12.

13.

Call the imerode function, passing the image BW and the structuring element SE as arguments.
BW2 = imerode(BW1,SE);
Notice the diagonal streaks on the right side of the output image. These are due to the shape of the
structuring element.
imshow(BW1)
figure, imshow(BW2)

Morphological Opening
You can use morphological opening to remove small objects from an image while preserving the shape and
size of larger objects in the image. For example, you can use the imopen function to remove all the circuit
lines from the original circuit image, circbw.tif, creating an output image that contains only the
rectangular shapes of the microchips.
To morphologically open the image, perform these steps:
1.

Read the image into the MATLAB workspace.

BW1 = imread('circbw.tif');
2.

Create a structuring element.


SE = strel('rectangle',[40 30]);
The structuring element should be large enough to remove the lines when you erode the image, but not
large enough to remove the rectangles. It should consist of all 1s, so it removes everything but large
contiguous patches of foreground pixels.

3.

Erode the image with the structuring element.

4.

BW2 = imerode(BW1,SE);
imshow(BW2)
This removes all the lines, but also shrinks the rectangles.

5.
6.

To restore the rectangles to their original sizes, dilate the eroded image using the same structuring
element, SE.
BW3 = imdilate(BW2,SE);
imshow(BW3)

Dilation- and Erosion-Based Functions


This section describes two common image processing operations that are based on dilation and erosion:

Skeletonization

Perimeter determination
This table lists other functions in the toolbox that perform common morphological operations that are based
on dilation and erosion.
Dilation- and Erosion-Based Functions

Function
bwhitmiss

imbothat

imclose

Morphological Definition
Logical AND of an image, eroded with one structuring element, and the images
complement, eroded with a second structuring element.
Subtracts the original image from a morphologically closed version of the image.
Can be used to find intensity troughs in an image.
Dilates an image and then erodes the dilated image using the same structuring
element for both operations.

imopen

Erodes an image and then dilates the eroded image using the same structuring
element for both operations.

imtophat

Subtracts a morphologically opened image from the original image. Can be used to
enhance contrast in an image.

Skeletonization
To reduce all objects in an image to lines, without changing the essential structure of the image, use
the bwmorph function. This process is known as skeletonization.
BW1 = imread('circbw.tif');
BW2 = bwmorph(BW1,'skel',Inf);
imshow(BW1)
figure, imshow(BW2)

Perimeter Determination
The bwperim function determines the perimeter pixels of the objects in a binary image. A pixel is
considered a perimeter pixel if it satisfies both of these criteria:

The pixel is on.

One (or more) of the pixels in its neighborhood is off.


For example, this code finds the perimeter pixels in a binary image of a circuit board.
BW1 = imread('circbw.tif');
BW2 = bwperim(BW1);
imshow(BW1)
figure, imshow(BW2)