You are on page 1of 7

DATA PERCOBAAN II

5 SEPTEMBER 2019

1. Operasi Threshold (Konversi citra Grayscale ke citra Biner)

clc; clf; clear all;


A=imread('cameraman.tif');
subplot(121)
imshow(A);
title('Citra awal');
[m n] = size(A);
for m = 1:255
for n= 1:255
if A(m,n)<=128;
B(m,n)=0;
elseif A(m,n)>=128;
B(m,n)=1;
end
end
end
subplot(122)
imshow(B)
title('Citra hasil');

Citra awal Citra hasil


2. Operasi Negatif

clc; clf; clear all;


A= imread('cameraman.tif');
subplot(121);
imshow(A);
title('Citra awal');

for m=1:255;
for n= 1:255
A= double(A);
B(m,n)= 255-A(m,n);
end
end

B = uint8(B);
subplot(122);
imshow(B)
title('Citra hasil')

Citra awal Citra hasil


3. Peningkatan Kontras

clc; clf; clear all;


A= imread('cameraman.tif');
subplot(121);
imshow(A);title('Citra awal');
for m= 1:255;
for n= 1:255
B(m,n) = A(m,n)+70;
end
end
B = uint8(B);
subplot(122);
imshow(B)
title('Citra hasil');

Citra awal Citra hasil


4. TUGAS
a.
clc; clf; clear all;
A= imread('cameraman.tif');
subplot(121);
imshow(A);title('Citra awal');
for m= 1:255;
for n= 1:255
B(m,n) = A(m,n)+20;
end
end
B = uint8(B);
subplot(122);
imshow(B)
title('Citra kecemerlangan 20');

Citra awal Citra kecemerlangan 20


b.
Citra awal Citra kecemerlangan 40
c.
clc; clf; clear all;
A= imread('cameraman.tif');
subplot(121);
imshow(A);title('Citra awal');
for m= 1:255;
for n= 1:255
B(m,n) = A(m,n)+60;
end
end
B = uint8(B);
subplot(122);
imshow(B)
title('Citra kecemerlangan 60');

Citra awal Citra kecemerlangan 60

You might also like