LAPORAN PORTOFOLIO
LAPORAN PORTOFOLIO
ANALISIS CITRA DAN VISI KOMPUTER
SEMESTER GENAP TAHUN AJARAN 2007/2008
[pic]
OLEH :
YANIDA YULIARI PUTRANTI (5104100027)
DOSEN :
ANNY YUNIARTI
JURUSAN TEKNIK INFORMATIKA
FAKULTAS TEKNOLOGI INFORMASI
INSTITUT TEKNOLOGI SEPULUH NOPEMBER
SURABAYA
2008
I. Identitas Diri
Nama : Yanida Yuliari Putranti
NRP : 5104100027
II. Link Web Portofolio
III. Listing Program
1. moments.m
% MOMENTS
%
% Fungsi menghitung momen sebuah citra biner dan mengembalikan
% area, centroid, sudut dari sumbu inertia minimum, dan sebuah
% ukuran ‘kebulatan'. Fungsi ini mengasumsikan bahwa hanya ada
% satu obyek pada citra biner.
%
% function [area, centroid, theta, roundness] = moments(im)
%
% Argument: im - citra biner berisi nilai 0 atau 1
%
% Returns: area - luasan citra biner
% centroid - vektor dengan 2 elemen
% theta - sudut sumbu kelembaman minimum (radian)
% roundness - ratio minimum inertia/maximum inertia.
%
% Fungsi ini juga menampilkan citra dan letak dari
% centroid dan sumbu inertia minimum. Area yang dihitung
% harus ditampilkan sebagai title di citra.
function [area, centroid, theta, roundness] = moments(im)
[bwl num] = prosbw(im);
%error handling
inImg = 0;
inImg = input(['Pilih image (1-',num2str(num),') = ']);
while (inImg < 1 || inImg > num)
inImg = input(['Input salah!!! Pilih image (1-',num2str(num),') = ']);
end
objek = bwl==inImg;
[rows,cols] = size(objek);
x = ones(rows,1)*[1:cols];
y = [1:rows]'*ones(1,cols);
%perhitungan area
area = sum(sum(double(objek)));
meanx = sum(sum(double(objek).*x))/area;
meany = sum(sum(double(objek).*y))/area;
%perhitungan centroid
centroid = [meanx meany];
xaksen = x - meanx;
yaksen = y - meany;
%perhitungan a, b, c
a = sum(sum(double(objek).*(xaksen.^2)));
b = 2 * sum(sum(((double(objek).* xaksen) .* yaksen)));
c = sum(sum((double(objek).* (yaksen.^2))));
%perhitungan theta
arg1 = b/(sqrt((b.^2)+((a-c).^2)));
arg2 = (a-c)/(sqrt((b.^2)+((a-c).^2)));
theta1 = 0.5 * atan2(arg1,arg2);
theta2 = 0.5 * atan2(-arg1,-arg2);
theta = theta1;
%perhitungan roundness
Imax = (0.5*(c+a))-(0.5*(a-c)*cos(2*theta2))-(0.5*b*sin(2*theta2));
Imin = (0.5*(c+a))-(0.5*(a-c)*cos(2*theta1))-(0.5*b*sin(2*theta1));
roundness = Imin/Imax;
%menampilkan hasil citra
xmin = [meanx - 50 : meanx + 50];
ymin = ((xmin - meanx) * tan(theta1)) + meany;
figure, imshow(objek), title(['Objek terpilih nomor: ' num2str(inImg), ', Area: ' num2str(area), ', Centroid: ' num2str(centroid), ', Theta: ' num2str(theta1), ', Roundness: ' num2str(roundness)]); pixval on;
line(xmin, ymin, 'Color', 'r', 'LineWidth', 1), text(meanx-3, meany, 'X');
i. prosbw.m
function [bwl num] = prosbw(im)
%membaca image
im = imread(im);
%mengubah image berwarna menjadi image graylevel
imgray = rgb2gray(im);
%nilai threshold
thresh = 0.63;
%mengubah image graylevel menjadi image biner sesuai dengan nilai threshold
%(bg 0 ob 1)
bw = ~im2bw(imgray, thresh);
%pelabelan tiap objek
[bwl num] = bwlabel(bw);
2. locatelandmarks.m
% LOCATELANDMARKS - locates landmarks on SURF form
%
% Usage: [tl, tr, bl, br] = locatelandmarks(im)
%
% Argument: im - Image to be processed, assumed binary.
%
% Returns: tl, tr, bl, br
% - Coordinates of the centroids of the top-left, top-right,
% bottom-left and bottom-right landmarks respectively.
% These coordinates are returned as column vectors in the
% form [row; col] for each landmark.
%
% The function should also display the image with the centroids of the
% landmarks overlayed.
function [tl, tr, bl, br] = locatelandmarks(im)
%membaca image
im = imread(im);
%mengubah image biner dengan bg hitam objek putih
imbw = ~im;
%operasi close - open untuk menghilangkan tulisan dengan se = 9
tempCent = [];
se = strel('square', 9);
openIM = imopen(imbw, se);
clsopnIM = imclose(openIM, se);
%pelabelan objek
[bwl num] = bwlabel(clsopnIM);
%perhitungan centroid untuk tiap objek
for i=1:num
objek = bwl==i;
[rows,cols] = size(objek);
x = ones(rows,1)*[1:cols];
y = [1:rows]'*ones(1,cols);
%perhitungan area
area = sum(sum(double(objek)));
meanx = sum(sum(double(objek).*x))/area;
meany = sum(sum(double(objek).*y))/area;
%perhitungan centroid
tempCent = [tempCent; meanx meany];
end
%memilih centroid objek yang berada dipojok citra
tl = [tempCent(1,1),tempCent(1,2)];
bl = [tempCent(2,1),tempCent(2,2)];
tr = [tempCent(num-1,1),tempCent(num-1,2)];
br = [tempCent(num,1),tempCent(num,2)];
%menampilkan hasil
figure, imshow(clsopnIM), title(['Objek landmarks, tl = (',num2str(tl(1,1)),',',num2str(tl(1,2)),'), tr = (',num2str(tr(1,1)),',',num2str(tr(1,2)),'), bl = (',num2str(bl(1,1)),',',num2str(bl(1,2)),'), br = (',num2str(br(1,1)),',',num2str(br(1,2)),')']);
text(tl(1,1)-5, tl(1,2)-3, 'x')
text(bl(1,1)-5, bl(1,2)-3, 'x')
text(tr(1,1)-5, tr(1,2)-3, 'x')
text(br(1,1)-5, br(1,2)-3, 'x')
pixval on;
3. tukarfase.m
function [hasil1, hasil2] = tukarfase(im, img)
im = imread(im);
imgray = rgb2gray(im);
img = imread(img);
imggray = rgb2gray(img);
%transformasi Fourier untuk citra 1 dan citra 2
ftransform1 = fft2(imgray);
ftransform2 = fft2(imggray);
%amplitudo transformasi Fourier
amplitudo1 = abs(ftransform1);
amplitudo2 = abs(ftransform2);
%sudut fase suatu transformasi Fourier
sudutfase1 = angle(ftransform1);
sudutfase2 = angle(ftransform2);
%fase dari transformasi Fourier untuk citra 1 dan citra 2
fase1 = exp(i*sudutfase1);
fase2 = exp(i*sudutfase2);
%tukar fase
%amplitudo citra 1 dengan fase citra 2
hasil1 = amplitudo1.* fase2;
%amplitudo citra 2 dengan fase citra 1
hasil2 = amplitudo2.* fase1;
%ifft
iffthasil1 = real(ifft2(hasil1));
iffthasil2 = real(ifft2(hasil2));
%menampilkan hasil
figure, subplot 221, imshow(im), title('Citra Asli 1');
subplot 222, imshow(iffthasil1, []), title('Amplitudo Citra 1; Fase Citra 2');
subplot 223, imshow(img), title('Citra Asli 2');
subplot 224, imshow(iffthasil2, []), title('Amplitudo Citra 2; Fase Citra 1');
figure, subplot 121, imshow(real(ifft2(fase1)), []), title('Fase Citra 1');
subplot 122, imshow(real(ifft2(fase2)), []), title('Fase Citra 2');
4. calibrate.m
% CALIBRATE
%
% Fungsi untuk melakukan kalibrasi kamera
%
% Usage: [C,e] = calibrate(im)
%
% Where: im - citra yang dijadikan sebagai target kalibrasi.
% C - matrix 3 x 4 kalibrasi kamera.
% e - nilai error proyeksi dari matrix kalibrasi.
function [C,e] = calibrate(im)
namafile = im;
im = imread(im);
image(im);
% Mendapatkan koordinat titik pada bidang 3D (real world)
% calibpts;
calibPts = [ 49 0 65 % x y z coords of point 1
129 0 65 % x y z coords of point 2
49 0 145 % x y z coords of point 3
129 0 145 % x y z coords of point 4
49 0 225 % x y z coords of point 5
129 0 225 % x y z coords of point 6
0 129 65 % x y z coords of point 7
0 49 65 % x y z coords of point 8
0 129 145 % x y z coords of point 9
0 49 145 % x y z coords of point 10
0 129 225 % x y z coords of point 11
0 49 225 ]; % x y z coords of point 12
disp('Titik koordinat pada bidang 3D calibPts = ');
disp(num2str(calibPts));
% N = jumlah titik yang dijadikan acuan
N = size(calibPts,1);
% Mendapatkan koordinat citra proyeksi 2D
% Mengklik tiap titik di bidang proyeksi
hold on
u = []; v = [];
but = 1;
while but ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.