Rabu, 22 Juni 2011

Menggelapkan dan Mencerahkan Gambar...

Mau tau caranyaaa...??
Bayar dulu doooonkkk....
Hahahahaha...................
Caranya agak panjang sihh.....
Yang pertama kita buat inisialisasi duluw..
// initialization
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Tag := 0; Edit2.Tag := 1; Edit3.Tag := 2;
Edit4.Tag := 3; Edit5.Tag := 4; Edit6.Tag := 5;
Edit7.Tag := 6; Edit8.Tag := 7; Edit9.Tag := 8;
Edit10.Tag := 9; // bias

SetMask(1, 1, 1,
1, 1, 1,
1, 1, 1, 0);

UndoBitmap := TBitmap.Create;
UndoBitmap.PixelFormat := pf24bit;
end;


kemudian baru coding untuk penggelapan dibuat..
Check it out...

procedure TForm1.ComboBox1Select(Sender: TObject);
begin
if ComboBox1.ItemIndex = 0 then // uniform smoothing
SetMask(1, 1, 1,
1, 1, 1,
1, 1, 1, 0);

if ComboBox1.ItemIndex = 1 then // gaussian smoothing
SetMask(1/36, 1/9, 1/36,
1/9, 4/9, 1/9,
1/36, 1/9, 1/36, 0);

if ComboBox1.ItemIndex = 2 then // edge detection
SetMask(-1, -1, -1,
-1, 8, -1,
-1, -1, -1, 0);

if ComboBox1.ItemIndex = 3 then // vertical edge detection
SetMask( 0, 0, 0,
-1, 2, -1,
0, 0, 0, 0);

if ComboBox1.ItemIndex = 4 then // horizontal edge detection
SetMask( 0, -1, 0,
0, 2, 0,
0, -1, 0, 0);

if ComboBox1.ItemIndex = 5 then // enhanced detail
SetMask( 0, -1, 0,
-1, 9, -1,
0, -1, 0, 0);

if ComboBox1.ItemIndex = 6 then // enhanced focus
SetMask(-1, 0, -1,
0, 7, 0,
-1, 0, -1, 0);

if ComboBox1.ItemIndex = 7 then // emboss filter
SetMask(-1, -1, 0,
-1, 0, 1,
0, 1, 1, 128);

if ComboBox1.ItemIndex = 8 then // lighten
SetMask( 0, 0, 0,
0, 1, 0,
0, 0, 0, 20);

if ComboBox1.ItemIndex = 9 then // darken
SetMask( 0, 0, 0,
0, 1, 0,
0, 0, 0, -20);
end;

Hasilnya...

0 komentar: