Sabtu, 28 Maret 2009

Image Thresholding / Pengambangan Citra

Dua nilai tingkat keabuan yaitu hitam dan putih. Secara umum proses pengambangan citra grayscale untuk menghasilkan citra biner adalah sebagai berikut.


g(x,y) adalah citra biner dari citra grayscale
f(x,y), dan T menyatakan nilai ambang. Nilai T memegang peranan yang sangat penting dalam proses pengambangan. Kualitas hasil citra biner sangat tergantung pada nilai T yang digunakan.

Metode Otsu
Metode Otsu menghitung nilai ambang T secara otomatis berdasarkan citra masukan. Pendekatan yang digunakan oleh metode Otsu adalah dengan melakukan analisis diskriminan yaitu menentukan suatu variabel yang dapat membedakan antara dua atau lebih kelompok yang muncul secara alami. Analisis Diskriminan akan memaksimumkan variabel tersebut agar dapat memisahkan objek dengan latar belakang.
Misalkan nilai ambang yang akan dicari dinyatakan dengan k. Nilai k berkisar antara 1 sampai dengan L, dengan L = 255. Probabilitas untuk piksel i dinyatakan dengan :



dengan ni menyatakan jumlah piksel dengan tingkat keabuan I, dan N menyatakan banyaknya piksel pada citra.
Nilai momen kumulatif ke-nol, momen kumulatif ke-satu, dan nilai rata-rata
berturut-turut dapat dinyatakan sebagai berikut :




Nilai ambang k dapat ditentukan dengan memaksimumkan persamaan:

dengan


Berikut Source Code Delphi Thresholding Otsu :


procedure TEnrollForm.Threshold(Image:TBitmap);
const level=255;
var
histogram: array[0..255] of integer;
PH: PByteArray;
TotalMean, Variance, maxVariance, zerothCumuMoment, firstCumuMoment : real;
i,j,k: integer;
p: PByteArray;
threshold:byte;
area: Word;

begin
for i:=0 to level do
begin
histogram[i]:=0;
end;
for i:=0 to Image.Height-1 do
begin
PH:=Image.ScanLine[i];
for j:= 0 to Image.Width-1 do
begin
inc(histogram[PH[3*j]]);
end;
end;

//compute otsu method
threshold:=0;
totalMean := 0;
maxVariance := 0;
firstCumuMoment := 0;
zerothCumuMoment := 0;
area := Image.Height * Image.Width;

for k:= 0 to level do
TotalMean := TotalMean + (k * histogram[k] / area);

for k:= 0 to level do
begin
zerothCumuMoment := zerothCumuMoment + histogram[k] / area;
firstCumuMoment := firstCumuMoment + (k * histogram[k] / area);
variance := totalMean * zerothCumuMoment - firstCumuMoment;
variance := variance * variance;

if ((zerothCumuMoment <> 0) and (zerothCumuMoment <> 1)) then
begin
variance := variance /(zerothCumuMoment * (1 - zerothCumuMoment));

if (maxVariance < variance) then
begin
maxVariance := variance;
threshold := k;
end;
end;
end;

for i:=0 to Image.Height-1 do begin
p:= Image.ScanLine[i];
for j:=0 to Image.Width-1 do begin
for k:=0 to 2 do
if (p[3*j])and (p[3*j+1]) and (p[3*j+2])>threshold then
p[3*j+k]:= 255
else
p[3*j+k]:= 0;
end;
end;
ImgThres.Picture.Bitmap:=Image;
end;

Selasa, 24 Maret 2009

Posting Source Code In Blogger

I Actually new in blogger, so i'm confuse how to post my source code in blogger.
After i search in Google, I found it's quitely simple to Posting Source Code In Blogger.

Here is the way we can do that..


<pre>
<code>


Your Source Code Here....



</pre>
</code>

wanna example click here

Minggu, 22 Maret 2009

Grayscale Image / Gambar Keabuan

Tujuan teknik grayscale adalah untuk mendapatkan citra keabuan. Untuk mendapatkan citra keabuan tersebut digunakan rumus:

I(x,y) adalah level keabuan pada suatu koordinat yang diperoleh dengan mengatur komposisi warna R (merah), G (hijau), B (biru) yang ditunjukkan oleh nilai parameter dan. Secara umum nilai dan adalah 0.33. Nilai yang lain juga dapat diberikan untuk ketiga parameter tersebut asalkan total keseluruhan nilainya adalah 1.

Berikut contoh Source code Grayscale Image di Delphi. Input adalah image dalam format TBitmap

procedure TFrm.Grayscale(Image:TBitmap);
var
i,j,k: Word;
p: PByteArray;

begin
Image.PixelFormat:= pf24Bit;
for i:=0 to Image.Height-1 do begin
p:= Image.ScanLine[i];
for j:=0 to Image.Width-1 do begin
p[3*j]:= (p[3*j]+p[3*j+1]+p[3*j+2])div 3;
for k:=0 to 2 do
p[3*j+k]:= p[3*j];
end;
end;

Citra1.Picture.Bitmap := Image; // membuat Citra 1 menjadi grayscale.
end;



Semoga Membantu..

Jumat, 20 Maret 2009

Increase our blogger Total Page Visited (TPV)

One of the manner that we can do to Increase Total Page Visited (TPV) in our blogger is one of the blogger.com advice to increase blog loading.


I think we just decrease number of post in index page. The little number of post cause the visitor do more browsing in our blog. The little number of post also affect good blog loading.

But do you know what the advantages of increase Total Page Visited (TPV) in SEO for...? I still don't get it.

Selasa, 17 Maret 2009

Make Rounded Image with Photoshop

Hello.. This is simple tutorial to make Rounded Image with Photoshop.

1. Open Image in photoshop
2. Duplicate Layer

3. Make Rounded with rounded tools (see the red elips in the picture). Don.t worry about the colour. It's not the final result.



4. Just Press CTRL + ENTER then CTRL + SHIFT + I (dont forget to see the layer condition in right side)



5. Adjust visible layer and delete.
(confuse..? see the layer condition in right side)



6. Adjust visible layer and Save




7. Save as PNG if you want it transparant in web page. Usually
Rounded Image using in webpage.
8. Done..




Sabtu, 14 Maret 2009

Euclidean Distance

Euclidean Distance use in 2 vektor similarity computation. Usually use in computer vision system. Euclidean distance compute root of square differences between 2 vectors. Euclidian Distance Formulas:

Example: 2 feature vector (A and B) :

Euclidean Distance between A dan B :

Euclidean distance is special case of Minkowski distance

with :