Pengolah Citra Digital 2

Download Report

Transcript Pengolah Citra Digital 2

Pengolah Citra Digital 2

Citra Gray & RGB Gray Red Green Blue

Definisi Citra Digital

12 155 67 ...

28 10 ...

...

Definisi Citra Digital

Screen 0 Image matrix 0 0 0 0 127 255 0 0 255 127 0 0 0 0 0

Proses Digitalisasi I(x, y) I(i, j)

DIGITALISASI (SCANNER)

Sampling Citra Kontinyu I(x, y)

Sampler

Definisi Histogram

Melihat Informasi Gambar • • imshow(‘coins.png’) imfinfo(‘coins.png’) • Cobalah untk gambar lain (pears.png, peppers.png, atau foto anda)

Menampilkan Histogram • • Figure, imshow(‘coins.png’) Figure, imhist(‘coins.png’) • Cobalah untk gambar lain (pears.png, peppers.png, atau foto anda)

Ekstraksi R, G dan B • • • • lenna = imread('lenna.jpg'); r = lenna(:,:,1); g = lenna(:,:,2); b = lenna(:,:,3);

Konversi ke Grayscale • • bisa dengan fungsi bawaan Matlab: – gray = rgb2gray(lenna); bisa disesuaikan dengan konstanta sendiri: – gray2 = .3*r + .2*g + .5*b;

Pseudocoloring • • • Gambar grayscale bisa kita buat seoalh2 berwarna dengan pesudo color Pseudocoloring dengan colormap contoh: – figure, imshow(r), colormap(jet), colorbar

Pseudocoloring

Konversi ke Citra Biner • • • citra biner adalah citra yang hanya direpresentasikan nilai tiap pixelnya dalam satu bit (satu nilai binary) – nilai pixel 0 berati hitam – nilai pixel1 berarti putih Konversi dilakukan dengan thresholding pada citra grayscale threshold bisa dihitung atau sembarang – nilai pixel dibawah threshold jadi 0 – nilai pixel diatas threshold jadi 1

Konversi ke Citra Biner • • • • • im = imread(‘japan.png’); imgray = rgb2gray(im); thresh = graythresh(imgray); imbw = im2bw(imgray, thresh); figure, imshow(imbw);

Operasi Citra

Deteksi Tepi BW = edge(I) BW = edge(I,'sobel') BW = edge(I,'prewitt') BW = edge(I,'roberts') BW = edge(I,'log') BW = edge(I,'canny')

Negasi

• • • • Negasi adalah proses pemetaan nilai pixel suatu citra, yaitu pada citra biner, pixel hitam dijadikan putih dan putih dijadikan hitam. Sedangkan pada citra grayscale atau berwarna, nilai maksimum pixel dikurangi dengan nilai pixel yang sedang diproses.

a=imread('bunga.jpg'); c=250-a;

Negasi figure,imshow(c)

Improve Image Contrast • • • • • • I = imread('pout.tif'); imshow(I) figure, imhist(I) I2 = histeq(I); figure, imshow(I2) figure, imhist(I2)

Write the Image to a Disk File • imwrite (I2, 'pout2.png');

Example • • • • • • • • • • • • • • • • • • • I = imread('rice.png'); imshow(I) background = imopen(I,strel('disk',15)); figure, imshow(background) I2 = imsubtract(I,background); figure, imshow(I2) I3 = imadjust(I2); figure, imshow(I3); level = graythresh(I3); bw = im2bw(I3,level); figure, imshow(bw) [labeled,numObjects] = bwlabel(bw,4); numObjects figure, imshow(labeled); impixelregion pseudo_color = label2rgb(labeled, @spring, 'c', 'shuffle'); figure, imshow(pseudo_color); graindata = regionprops(labeled,'basic') area51 = graindata(51).Area

Rotating an Image • • • • I = imread('circuit.tif'); J = imrotate(I,35,'bilinear'); imshow(I) figure, imshow(J)