0% found this document useful (0 votes)
42 views3 pages

Script Matlab: 1. Operasi Titik Penambahan Dan Pengurangan Intensitas Citra

The document describes various image processing operations in Matlab including: 1. Increasing and decreasing image intensity by adding and subtracting values from each pixel. 2. Equalizing the image histogram to improve contrast. 3. Smoothing images using low pass filtering to reduce noise. 4. Sharpening images using high pass filtering to enhance edges. 5. Reducing salt and pepper noise using median filtering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views3 pages

Script Matlab: 1. Operasi Titik Penambahan Dan Pengurangan Intensitas Citra

The document describes various image processing operations in Matlab including: 1. Increasing and decreasing image intensity by adding and subtracting values from each pixel. 2. Equalizing the image histogram to improve contrast. 3. Smoothing images using low pass filtering to reduce noise. 4. Sharpening images using high pass filtering to enhance edges. 5. Reducing salt and pepper noise using median filtering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Operasi titik penambahan dan pengurangan intensitas citra

Script Matlab
a = imread('rr.jpg')
b = a+100;
c = a-50;
imshow([a b c]);

2. Operasi titik melalui ekualisasi histrogram

Script Matlab
a = imread('rr.jpg');
b = histeq(a);
imshow([a b]);

3. Operasi ruang, pebaikan dilakukan menggunakan LPF (Low Pass Filtering) / Smoothing

Script Matlab
clear; clc;
A = imread('rr.jpg');
A = imnoise(A, '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
figure, imshow(A);
figure, imshow(uint8(B));
4. Operasi ruang, perbaikan dilakukan menggunakan HPF (High Pass Filtering) / Sharpening

Script Matlab
I = imread('rr.jpg');
hpf =[-1 -1 -1; -1 9 -1; -1 -1 -1];
[r, c] = size(I);
[m, n] = size(hpf);
h = rot90(hpf, 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
figure, imshow(I);
figure, imshow(uint8(B))
5. Filter Median

Script Matlab
clear; clc;
I = imread('rr.jpg');
I = imnoise(I, 'salt & pepper', 0.01);
[r, c] = size(I);
Rep = zeros(r + 2, c + 2);
for x = 2 : r + 1
for y = 2 : c + 1
Rep(x,y) = I(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
figure, imshow(I);
figure, imshow(uint8(B))

You might also like