You are on page 1of 6

Modul 10

Morphological Operations

10.1 Tujuan

Mempelajari tentang operasi-operasi morphologi

10.2 Dasar Teori

Morfologi adalah teknik pengolahan citra berdasarkan bentuk. Nilai setiap pixel dalam
gambar output berdasarkan perbandingan pixel yang sesuai dengan tetangganya. Dengan
memilih ukuran dan bentuk, maka dapat membangun sebuah operasi morfologi yang sensitif
terhadap bentuk tertentu pada input gambar. Fungsi morfologi dapat digunakan untuk
pengolahan citra secara umum. Misalnya peningkatan kontras, penghilangan noise, penipisan,
skeletonization dan segmentasi.

A. Dilasi dan Erosi


Dilasi dan erosi merupakan dua operasi dasar morfologi. Dilasi menambahkan pixel
dengan batas-batas objek dalam gambar. Sedangkan erosi menghilangkan pixel pada
batas-batas objek. Jumlah pixel ditambahkan atau dihapus dari noise tergantung pada
ukuran dan bentuk.
B. Simulink
Digunakan untuk melihat simulasi image sebelum morfologi dan setelah morfologi.
Bagian utama terdiri atas :
-image from file
- opening
-video viewer
-Relational operator
-Label
-Display

10.3 Langkah Percobaan

1. Dilation and Erosion


Structuring Element
The Origin of a Structuring Element
>>nhood=imread(‘pout.tif’);
>>origin=floor ((size(nhood)+1)/2)
2. Dilating an image
>>BW=zeros(9,10)
>>BW(4:6 , 4:7) = 1
>>SE=strel(‘square’,3)
>>BW2=imdilate(BW,SE)
3. Eroding an image
>>BW1 = imread('circbw.tif');
>>SE = strel('arbitrary',eye(5));
>>BW2 = imerode(BW1,SE);
>>imshow(BW1)
>>figure, imshow(BW2)
4. Combining Dilation and Erosion
>> BW1 = imread (‘circbw.tif’);
>>SE = strel(‘rectangel’,[40 30]);
>>BW2 = imerode(BW1,SE);
>>imshow(BW2)
>>BW3 = imdilate(BW2,SE);
>>imshow(BW3)
5. Dilation- and Erosion-Based Functions
Skeletonization
>>BW1 = imread('circbw.tif');
>>BW2 = bwmorph(BW1,'skel',Inf);
>>imshow(BW1)
>>figure, imshow(BW2)
Perimeter Determination
>>BW1 = imread('circbw.tif');
>>BW2 = bwperim(BW1);
>>imshow(BW1)
>>figure, imshow(BW2)
6. Marker and Mask
Morphological reconstruction processes one image, called the marker, based on the
characteristics of another image, called the mask. The high points, or peaks, in the marker
image specify where processing begins. The processing continues until the image values stop
changing.
>> marker = imsubtract(A,2)
>>marker=
>>recon = imreconstruct(marker, mask)
7. Pixel Connectivity
>> CONN = [ 0 1 0; 0 1 0; 0 1 0 ]
>>CONN =
8. Flood-Fill Operations
Specifying the Starting Point
>>imfill(BW,[4 3])
>> imfill(BW,[4 3],8)
9. Filling Holes
>>[X,map] = imread('spine.tif');
>>I = ind2gray(X,map);
>>Ifill = imfill(I,'holes');
>>imshow(I);figure, imshow(Ifill)
10. Finding Peaks and Valleys
Finding Areas of High or Low Intensity
>>

>> B= imregionalmax(A)

>>B= imextendedmax(A,2)

Suppressing Minima and Maxima

>>

>> B = imhmax(A,2)

Imposing a Minimum

>>mask = uint8(10*ones(10,10));

>>mask(6:8,6:8) = 2;

>>mask(2:4,2:4) = 7;

>>mask(3,3) = 5;

>>mask(2,9) = 9

>>mask(3,8) = 9

>>mask(9,2) = 9
>>mask(8,3) = 9

Creating a Marker Image

>>marker = imextendedmin(mask,1)

Applying the Marker Image to the Mask

>> I = imimposemin(mask,marker)

11. Distance Transform

>>center1 = -10;

>>center2 = -center1;

>>dist = sqrt(2*(2*center1)^2);

>>radius = dist/2 * 1.4;

>>lims = [floor(center1-1.2*radius) ceil(center2+1.2*radius)];

>> [x,y] = meshgrid(lims(1):lims(2));

>>>>bw1 = sqrt((x-center1).^2 + (y-center1).^2) <= radius;

>>bw2 = sqrt((x-center2).^2 + (y-center2).^2) <= radius;

>>bw = bw1 | bw2;

>>figure, imshow(bw), title('bw')

To compute the distance transform of the complement of the binary image, use the bwdist
function. In the image of the distance transform, note how the centers of the two circular
areas are white.

>>D = bwdist(~bw);

>>figure, imshow(D,[J]), title('Distance transform of ~bw')

12. Connected-Component Labeling

BW = [0 0 0 0 0 0 0 0;

0 1 1 0 0 1 1 1;

0 1 1 0 0 0 1 1;

0 1 1 0 0 0 0 0;

0 0 0 1 1 0 0 0;

0 0 0 1 1 0 0 0;
0 0 0 1 1 0 0 0;

0 0 0 0 0 0 0 0];

X = bwlabel(BW,4)

13. Viewing a Label Matrix

X = bwlabel(BW1,4);

RGB = label2rgb(X, @jet, 'k');

imshow(RGB,'notruesize')

14. Finding the Area of the Foreground of a Binary Image

BW = imread('circbw.tif');
SE = ones(5);
BW2 = imdilate(BW,SE);
increase = (bwarea(BW2) - bwarea(BW))/bwarea(BW);
increase =
0.3456
15. Finding the Euler Number of a Binary Image

BW1 = imread('circbw.tif');
eul = bweuler(BW1,8)
eul =
-85
16. Lookup Table Operations
BW1 = imread('text.png');
BW2 = applylut(BW1,lut);
imshow(BW1)
figure, imshow(BW2)
17. PERCOBAAN PADA SIMULINK
Sebelum transformasi
Setelah Transformasi

10.4 Tugas
Analisa percobaan diatas dan beri kesimpulan !

You might also like