0% found this document useful (0 votes)
26 views4 pages

Jovita Yumna Kultum - Tugas 4

tugas 4 pengolahan citra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

Jovita Yumna Kultum - Tugas 4

tugas 4 pengolahan citra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Nama : Jovita Yumna Kultum

NIM : 210604110024

TUGAS 4

a. Histogram
Code:
I = imread('2.jpg');
B = rgb2gray(I);
J = imadjust(B,[0 0.2],[0.5 1]);
figure,imshow(B);
figure,imhist(B);
figure,imshow(J);
figure,imhist(J);

Hasil:
b. filtermedian
Code:
I = imread('1.jpg');
A = imnoise(I, 'salt & pepper', 0.01);
[r c] = size(A);
Rep = zeros(r +2, c + 2);
for x = 2 : r + 1
for y = 2 : c + 1
Rep(x,y) = A(x - 1, y - 1);
end
end
Rep; B = zeros(r, c);
for x = 1 : r
for y = 1 : c
for i = 1 : 3
for j = 1 : 3
q = x - 1;
w = y - 1;
array((i - 1) * 3 + j) = Rep(i + q, j + w);
end
end
B(x, y) = median(array(:));
end
end
subplot (1,2,1); imshow(I);
subplot (1,2,2); imshow(uint8(B));

Hasil:
c. Pelembut 3x3
Code:
I = imread('2.jpg');
A = imnoise(I, 'salt & pepper', 0.01);
k = ones(3) / 9;
[r c] = size(A);
[m n] = size(k);
h = rot90(k, 2);
center = floor((size(h)+1)/2);
left = center(2) - 1;
right = n - center(2);
top = center(1) - 1;
bottom = m - center(1);
Rep = zeros(r + top + bottom, c + left + right);
for x = 1 + top : r + top
for y = 1 + left : c + left;
Rep(x,y) = A(x - top, y - left);
end
end
B = zeros(r , c);
for x = 1 : r
for y = 1 : c
for i = 1 : m
for j = 1 : n
q = x - 1;
w = y - 1;
B(x, y) = B(x, y) + (Rep(i + q, j + w) * h(i,j));
end
end
end
end
C=rgb2gray(A);
subplot (1,2,1); imshow(C);
subplot (1,2,2); imshow(uint8(B));

Hasil:
d. Penajaman
Code:
I = imread('1.jpg');
hpf =[-1 -1 -1; -1 9 -1; -1 -1 -1];
[r c] = size(I);
[m n] = size(hpf);
h = rot90(k, 2);
center = floor((size(h)+1)/2);
left = center(2) - 1;
right = n - center(2);
top = center(1) - 1;
bottom = m - center(1);
Rep = zeros(r + top + bottom, c + left + right);
for x = 1 + top : r + top
for y = 1 + left : c + left;
Rep(x,y) = I(x - top, y - left);
end
end
B = zeros(r , c);
for x = 1 : r
for y = 1 : c
for i = 1 : m
for j = 1 : n
q = x - 1;
w = y - 1;
B(x, y) = B(x, y) + (Rep(i + q, j + w) * h(i,j));
end
end
end
end
subplot (1,2,1); imshow(I);
subplot (1,2,2); imshow(uint8(B));

Hasil:

You might also like