Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
JagoVB JagoVB is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 508
Rep Power: 14
JagoVB mempunyai hidup yang Normal
Default Image Sharpening J2ME

Saia nyoba2 bikin aplikasi J2ME buat menajamkan citra (image sharpening), trus saia punya contoh aplikasi tp dlm format Delphi.

Algoritma sharpening-nya pake masking kaia gini:


Code:

mask[-1,-1] := 0;
mask[ 0,-1] := -alpha;
mask[ 1,-1] := 0;
mask[-1, 0] := -alpha;
mask[ 0, 0] := 1+4*alpha;
mask[ 1, 0] := -alpha;
mask[-1, 1] := 0;
mask[ 0, 1] := -alpha;
mask[ 1, 1] := 0;

w := FormCitra.Image.Picture.Width;
h := FormCitra.Image.Picture.Height;
if (FormCitra.Image.Picture.Bitmap.PixelFormat = pf8bit)
then
begin
SetLength(Ki, w, h);
SetLength(Ko, w, h);
for y := 0 to h-1 do
begin
PC := FormCitra.Image.Picture.Bitmap.ScanLine[y];
PH := FormHasil.Image.Picture.Bitmap.ScanLine[y];
for x := 0 to w-1 do
begin
Ki[x, y] := PC[x];
Ko[x, y] := PH[x];
end;
end;
for x := 1 to w-2 do
for y := 1 to h-2 do
begin
jumlah := 0;
for u := -1 to 1 do
for v := -1 to 1 do
jumlah := jumlah+Mask[u,v]*Ki[x-u,y-v];
if (jumlah255) then
Ko[x,y] := 255
else
Ko[x,y] := Round(jumlah)
end;
for y := 0 to h-1 do
begin
PH := FormHasil.Image.Picture.Bitmap.ScanLine[y];
for x := 0 to w-1 do
PH[x] := Ko[x, y];
end;
Ki := nil;
Ko := nil;
end;

Dari analisa saia, algoritma tsb menajamkan suatu piksel dengan cara melakukan operasi penjumlahan dg piksel2 di sekitarnya melalui operasi masking.

Operasi tsb mengambil sampel piksel berbentuk matriks 3x3, dg piksel yg berada di tengah merupakan piksel target operasi, kira2 gambarannya kaia gini matriksnya:

+ + +

+ * +

+ + +



(bener ga ya? )



Trus saia konversi ke J2ME, jadinya:


Code:

public static Image sharpen(Image srcImage)
{
Image imgOut=Image.createImage(srcImage.getWidth(), srcImage.getHeight());

int mask[][]={{0,-1,0},{-1,1+4,-1},{0,-1,0}};
int x,y,u,v,jumlah;
double r,g,b;
int tmp[];
Graphics gr=imgOut.getGraphics();

for(x=1;x

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 11:07 PM.


no new posts