Analisis Perbandingan Geometric Mean Filter Dengan Operator Sobel, Operator Prewitt Dan Operator Robert Pada Citra Bitmap

(1)

LISTING PROGRAM

1. Mainform.cs

using System;

using System.Drawing;

using System.Windows.Forms;

namespace AnalisisPerbandinganFilertingdanDeteksiTepi {

public partial class MainForm : Form {

public MainForm() {

InitializeComponent(); }

void FilteringToolStripMenuItemClick(object sender, EventAr s e) {

Filtering a = new Filtering(); this.Hide();

a.ShowDialog(); }

void DeteksiTepiToolStripMenuItemClick(object sender, EventArgs e) {

DeteksiTepi a = new DeteksiTepi(); this.Hide();

a.ShowDialog(); }

void AboutToolStripMenuItemClick(object sender, EventArgs e) {

Help a = new Help(); this.Hide();

a.ShowDialog(); }

void AboutToolStripMenuItem1Click(object sender, EventArgs e) {

About a = new About(); this.Hide();

a.ShowDialog(); }

void ExitToolStripMenuItemClick(object sender, EventArgs e) {

if (MessageBox.Show("Are you sure to exit the

Aplication?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

Application.Exit(); }

} }


(2)

2. Filtering.cs

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data;

using System.Drawing;

using System.Drawing.Imaging; using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Runtime.InteropServices; using System.Diagnostics;

using System.IO;

namespace AnalisisPerbandinganFilertingdanDeteksiTepi {

public partial class Filtering : Form {

Bitmap img; bool bitdev; double Dev;

double probabilitas;

IntPtr point = IntPtr.Zero; public Filtering()

{

InitializeComponent(); }

Bitmap geometric(Bitmap image) {

int lebar = image.Width; int panjang = image.Height;

double merah = 0, hijau = 0, biru = 0, hasilred = 1, hasilgreen = 1, hasilblue = 1;

double redfinal, greenfinal, bluefinal;

Bitmap imagehasil = new Bitmap(lebar, panjang); for (int i = 0; i < panjang-2; i++)

{

for (int j = 0; j < lebar-2; j++) {

for (int k = i; k <= i + 2; k++) {

for (int l = j; l <= j + 2; l++) {

merah = image.GetPixel(l, k).R; if (merah == 0)

merah = 255;

hijau = image.GetPixel(l, k).G; if (hijau == 0)

hijau = 255;


(3)

if (biru == 0) biru = 255; hasilred *= merah; hasilgreen *= hijau; hasilblue *= biru; }

}

redfinal = Math.Pow(hasilred,(1.0/9.0)); double RED = Math.Round(redfinal);

greenfinal = Math.Pow(hasilgreen,(1.0/9.0)); double GREEN = Math.Round(greenfinal, 0); bluefinal = Math.Pow(hasilblue,(1.0/9.0)); double BLUE = Math.Round(bluefinal, 0);

imagehasil.SetPixel(j + 1, i + 1, Color.FromArgb(255, (in t)RED, (int)GREEN, (int)BLUE));

hasilred = 1; hasilgreen = 1; hasilblue = 1; }

}

return imagehasil; }

void HomeToolStripMenuItemClick(object sender, EventArgs e) {

MainForm a = new MainForm(); this.Hide();

a.ShowDialog(); }

void DeteksiTepiToolStripMenuItemClick(object sender, EventArgs e) {

DeteksiTepi a = new DeteksiTepi(); this.Hide();

a.ShowDialog(); }

void AboutToolStripMenuItemClick(object sender, EventArgs e) {

Help a = new Help(); this.Hide();

a.ShowDialog(); }

void AboutToolStripMenuItem1Click(object sender, EventArgs e) {

About a = new About(); this.Hide();

a.ShowDialog(); }

void PictureBox4Click(object sender, EventArgs e) {

try {

OpenFileDialog oFile = new OpenFileDialog(); oFile.Filter = "Images File(*.bmp)|*.bmp";


(4)

if (oFile.ShowDialog() == DialogResult.OK) {

Bitmap cit = new Bitmap (oFile.FileName); if (cit.Height <= 300 && cit.Width <= 300) {

pcitraAsli.Image = cit; img

= new Bitmap(new Bitmap(oFile.FileName), pcitraAsli.Width, pcitraAsli.Height) ;

pcitraAsli.Image = img;

textBox6.Text=cit.Width.ToString(); textBox5.Text=cit.Height.ToString();

textBox4.Text=oFile.SafeFileName.ToString(); }

else

MessageBox.Show("Image Pixel must be 300x300", "Warning"); }

}

catch (Exception) {

throw new ApplicationException("Failed Loading !"); }

}

void ClearClick(object sender, EventArgs e) {

pcitraAsli.Image=null; pcitraNoise.Image=null; pcitraFilter.Image=null;

textBox4.Text=""; textBox5.Text=""; textBox6.Text="";

comboBox1.Text=null; }

void ExitToolStripMenuItemClick(object sender, EventArgs e) {

if (MessageBox.Show("Are you sure to exit the

Aplication?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

Application.Exit(); }

private double getGaussianNumbers() {

Random rand = new Random(); double x, y, kotak;

if (bitdev) {

bitdev = false; return Dev * 1; }

do {


(5)

y = 2 * rand.NextDouble() - 1; kotak = x * x + y * y;

}

while (kotak >= 1 || kotak == 0); var kutub =

Math.Sqrt(-2 * Math.Log(kotak) / kotak); Dev = y * kutub; bitdev = true; return x * kutub; }

void SaveClick(object sender, EventArgs e)

{

if(pcitraFilter.Image != null) {

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {

pcitraFilter.Image.Save(save.FileName, System.Drawing .Imaging.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

void GeometricMeanFIlterClick(object sender, EventArgs e) {

Bitmap bit = new Bitmap(pcitraNoise.Image); pcitraFilter.Image=geometric(bit);

}

void GaussianClick(object sender, EventArgs e) {

Bitmap citraAsli = new Bitmap(pcitraAsli.Image); int x = citraAsli.Width;

int y = citraAsli.Height; Bitmap citraHasil = citraAsli;

if ((comboBox1.Text) == "10%") probabilitas = 10;

else if ((comboBox1.Text) == "20%") probabilitas = 20;

else if ((comboBox1.Text) == "30%") probabilitas = 30;

else if ((comboBox1.Text) == "40%") probabilitas = 40;

else if ((comboBox1.Text) == "50%") probabilitas = 50;


(6)

double gaussianNumber = 0.0;

int step, newPixel, pixelSize = x * y; BitmapData bmpData = null;

byte[] Pxl;

Random rnd = new Random();

Rectangle box = new Rectangle(0, 0, x, y); int Depth =

System.Drawing.Bitmap.GetPixelFormatSize(citraAsli.PixelFormat); step = Depth / 8;

bmpData =

citraAsli.LockBits(box, ImageLockMode.ReadWrite, citraAsli.PixelFormat); Pxl = new byte[pixelSize * step];

point = bmpData.Scan0;

Marshal.Copy(point, Pxl, 0, Pxl.Length); for (int i = 0; i < Pxl.Length; i += step) {

if (i < Pxl.Length - step) {

for (int j = 0; j < step; j++) {

gaussianNumber = getGaussianNumbers(); newPixel =

Convert.ToInt32(gaussianNumber * probabilitas) + Convert.ToInt32(Pxl[i + j]); if (newPixel < 0) newPixel = 0;

if (newPixel > 255) newPixel = 255;

Pxl[i + j] = Convert.ToByte(newPixel); }

} }

Marshal.Copy(Pxl, 0, point, Pxl.Length); citraAsli.UnlockBits(bmpData);

pcitraNoise.Image=citraAsli; }

void SaltpepperClick(object sender, EventArgs e) {

Bitmap citraAsli = new Bitmap(pcitraAsli.Image); int x = citraAsli.Width;

int y = citraAsli.Height; Bitmap citraHasil = citraAsli; if ((comboBox1.Text) == "10%")

probabilitas = Convert.ToInt32(0.1*x*y); else if ((comboBox1.Text) == "20%") probabilitas = Convert.ToInt32(0.2*x*y); else if ((comboBox1.Text) == "30%") probabilitas = Convert.ToInt32(0.3*x*y); else if ((comboBox1.Text) == "40%") probabilitas = Convert.ToInt32(0.4*x*y); else if ((comboBox1.Text) == "50%") probabilitas = Convert.ToInt32(0.5*x*y); int x1,y1,val;

Random rand = new Random();


(7)

{

x1 = rand.Next(0,x-1); y1 = rand.Next(0,y-1); val = rand.Next(1,10); if (val <= 5)

{

citraHasil.SetPixel(x1,y1,Color.FromArgb(255,0,0,0)); }

else {

citraHasil.SetPixel(x1,y1,Color.FromArgb(255,255,255, 255));

} }

pcitraNoise.Image=citraAsli; }

void Button1Click(object sender, EventArgs e) {

if(pcitraNoise.Image != null) {

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {

pcitraNoise.Image.Save(save.FileName, System.Drawing. Imaging.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

} }

3. Deteksi Tepi

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data;

using System.Linq;

using System.Diagnostics; using System.IO;

using System.Drawing;

using System.Drawing.Imaging; using System.Text;


(8)

using System.Runtime.InteropServices;

namespace AnalisisPerbandinganFilertingdanDeteksiTepi {

public partial class DeteksiTepi : Form {

Bitmap img;

public DeteksiTepi() {

InitializeComponent(); }

void HomeToolStripMenuItemClick(object sender, EventArgs e) {

MainForm ua = new MainForm(); this.Hide();

ua.ShowDialog (); }

void FilteringToolStripMenuItemClick(object sender, EventArgs e) {

Filtering us = new Filtering(); this.Hide();

us.ShowDialog(); }

void AboutToolStripMenuItemClick(object sender, EventArgs e) {

Help uf = new Help(); this.Hide();

uf.ShowDialog(); }

void AboutToolStripMenuItem1Click(object sender, EventArgs e) {

About ug = new About(); this.Hide();

ug.ShowDialog(); }

void PictureBox5Click(object sender, EventArgs e) {

try {

OpenFileDialog oFile = new OpenFileDialog(); oFile.Filter = "Images File(*.bmp)|*.bmp"; if (oFile.ShowDialog() == DialogResult.OK) {

Bitmap cit = new Bitmap (oFile.FileName); if (cit.Height <= 300 && cit.Width <= 300) {

citraAsli.Image = cit; img

= new Bitmap(new Bitmap(oFile.FileName), citraAsli.Width, citraAsli.Height); citraAsli.Image = img;


(9)

textBox2.Text=cit.Height.ToString();

textBox3.Text=oFile.SafeFileName.ToString(); }

else

MessageBox.Show("Image Pixel must be 300x300", "Warning");

} }

catch (Exception) {

throw new ApplicationException("Failed Loading !"); }

}

void PictureBox8Click(object sender, EventArgs e) {

try {

OpenFileDialog oFile = new OpenFileDialog(); oFile.Filter = "Images File(*.bmp)|*.bmp"; if (oFile.ShowDialog() == DialogResult.OK) {

Bitmap cit = new Bitmap (oFile.FileName); if (cit.Height <= 300 && cit.Width <= 300) {

citraFiltering.Image = cit; img

= new Bitmap(new Bitmap(oFile.FileName), citraFiltering.Width, citraFiltering .Height);

citraFiltering.Image = img;

textBox9.Text=cit.Width.ToString(); textBox7.Text=cit.Height.ToString();

textBox8.Text=oFile.SafeFileName.ToString(); }

else

MessageBox.Show("Image Pixel must be 300x300", "Warning");

} }

catch (Exception) {

throw new ApplicationException("Failed Loading !"); }

}

void ClearDeteksiClick(object sender, EventArgs e) {

citraAsli.Image=null; citraFiltering.Image=null; pSobel.Image=null;

pRobert.Image=null; pPrewitt.Image=null; pfSobel.Image=null; pfPrewitt.Image=null; pfRobert.Image=null;

textBox1.Text=null;textBox2.Text=null;textBox3.Text=null; textBox7.Text=null;textBox8.Text=null;textBox9.Text=null;


(10)

textBoxs1.Text=null;textBoxs2.Text=null;textBoxs3.Text=null; textBoxs4.Text=null;textBoxs5.Text=null;textBoxs6.Text=null; textBoxp1.Text=null;textBoxp2.Text=null;textBoxp3.Text=null; textBoxp4.Text=null;textBoxp5.Text=null;textBoxp6.Text=null; textBoxr1.Text=null;textBoxr2.Text=null;textBoxr3.Text=null; textBoxr4.Text=null;textBoxr5.Text=null;textBoxr6.Text=null; }

void ExitToolStripMenuItemClick(object sender, EventArgs e) {

if (MessageBox.Show("Are you sure to exit the

Aplication?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

Application.Exit(); }

private Bitmap SobelEdgeDetect(Bitmap original) {

Bitmap sobel = new Bitmap(original); int [,] arr_r;

int [,] arr_g; int [,] arr_b; byte[,] temp_array;

arr_r = new int[sobel.Width, sobel.Height]; arr_g = new int[sobel.Width, sobel.Height]; arr_b = new int[sobel.Width, sobel.Height]; temp_array=new byte[sobel.Width, sobel.Height]; double x;

double y; double grad;

for (int i = 1; i < (sobel.Width - 1); i++) {

for (int j = 1; j < (sobel.Height - 1); j++) {

arr_r[i, j] = original.GetPixel(i, j).R; arr_g[i, j] = original.GetPixel(i, j).G; arr_b[i, j] = original.GetPixel(i, j).B;

arr_r[i, j] = (arr_r[i, j] + arr_g[i, j] + arr_b[i, j]) / 3;

} }

for (int i = 1; i < (sobel.Width-1); i++) {

for (int j = 1; j < (sobel.Height-1); j++) {

x=System.Math.Abs(1*arr_r[i1,j1]+2*arr_r[i1,j] + 1*arr_r[i1,j+1] arr_r[i+1, j1] 2 * arr_r[i+1, j] arr_r[i + 1, j + 1]);

y=System.Math.Abs(1*arr_r[i-1,j-1]+2*arr_r[i,j-1]+1*arr_r[i+1,j-1]-1*arr_r[i-1,j+1]-2*arr_r[i,j+1]-1*arr_r[i+1,j+1]);


(11)

grad = System.Math.Sqrt(x*x+y*y); if ( grad > 255) grad =255;

temp_array[i, j] =(byte)(grad);

sobel.SetPixel(i,j,Color.FromArgb(temp_array[i, j],tem p_array[i, j],temp_array[i,j]));

} }

return sobel; }

private Bitmap PrewittEdgeDetect(Bitmap original) {

Bitmap prewitt = new Bitmap(original); int [,] arr_r;

int [,] arr_g; int [,] arr_b; byte[,] temp_array;

arr_r = new int[prewitt.Width, prewitt.Height]; arr_g = new int[prewitt.Width, prewitt.Height]; arr_b = new int[prewitt.Width, prewitt.Height]; temp_array=new byte[prewitt.Width, prewitt.Height]; double x;

double y; double grad;

for (int i = 1; i < (prewitt.Width - 1); i++) {

for (int j = 1; j < (prewitt.Height - 1); j++) {

arr_r[i, j] = original.GetPixel(i, j).R; arr_g[i, j] = original.GetPixel(i, j).G; arr_b[i, j] = original.GetPixel(i, j).B;

arr_r[i, j] = (arr_r[i, j] + arr_g[i, j] + arr_b[i, j]) / 3;

} }

for (int i = 1; i < (prewitt.Width-1); i++) {

for (int j = 1; j < (prewitt.Height-1); j++) {

x=System.Math.Abs(1*arr_r[i1,j1]+1*arr_r[i1,j] + 1*arr_r[i1,j+1] 1 * arr_r[i+1, j1] 1* arr_r[i+1, j] 1*arr_r[i + 1, j + 1]);

y=System.Math.Abs(1*arr_r[i-1,j-1]+1*arr_r[i,j-1]+1*arr_r[i+1,j-1]-1*arr_r[i-1,j+1]-1*arr_r[i,j+1]-1*arr_r[i+1,j+1]); grad = System.Math.Sqrt(x*x+y*y);

if ( grad > 255) grad =255; temp_array[i, j] =(byte)(grad);

prewitt.SetPixel(i,j,Color.FromArgb(temp_array[i, j],t emp_array[i, j],temp_array[i,j]));

} }


(12)

return prewitt; }

private Bitmap RobertEdgeDetect(Bitmap original) {

Bitmap robert = new Bitmap(original); int [,] arr_r;

int [,] arr_g; int [,] arr_b; byte[,] temp_array;

arr_r = new int[robert.Width, robert.Height]; arr_g = new int[robert.Width, robert.Height]; arr_b = new int[robert.Width, robert.Height]; temp_array=new byte[robert.Width, robert.Height]; double x;

double y; double grad;

for (int i = 1; i < (robert.Width - 1); i++) {

for (int j = 1; j < (robert.Height - 1); j++) {

arr_r[i, j] = original.GetPixel(i, j).R; arr_g[i, j] = original.GetPixel(i, j).G; arr_b[i, j] = original.GetPixel(i, j).B;

arr_r[i, j] = (arr_r[i, j] + arr_g[i, j] + arr_b[i, j]) / 3;

} }

for (int i = 0; i < (robert.Width-1); i++) {

for (int j = 0; j < (robert.Height-1); j++) {

x=System.Math.Abs(arr_r[i, j] - arr_r[i + 1, j + 1]); y=System.Math.Abs(arr_r[i + 1, j] - arr_r[i, j + 1]);

grad = x+y;

if ( grad > 255) grad =255; temp_array[i, j] =(byte)(grad);

robert.SetPixel(i,j,Color.FromArgb(temp_array[i, j],te mp_array[i, j],temp_array[i,j]));

} }

return robert; }

void RobertFilterClick(object sender, EventArgs e) {

Stopwatch time = new Stopwatch(); time.Start();

Bitmap bit = new Bitmap(citraFiltering.Image); int x = bit.Height; int y = bit.Width;

double rd=0,bl=0,gr=0,gy=0;


(13)

for (int i = 0; i < x-1; i++) {

for (int j = 0; j <= y-1; j++) {

rd = bit.GetPixel(i,j).R; if (rd <=0)

rd = 255;

gr = bit.GetPixel(i,j).G; bl = bit.GetPixel(i,j).B;

gy = (rd*0.3 + gr*0.59 + bl*0.11);

imageHasil.SetPixel(i,j,Color.FromArgb((int)gy,(int)gy,(i nt)gy));

gy = 0; }

}

pfRobert.Image=RobertEdgeDetect(imageHasil); time.Stop();

textBoxr6.Text =

Math.Round(Convert.ToDecimal(time.ElapsedMilliseconds)/1000,4).ToString(); textBoxr4.Text

= hitungMSE((Bitmap)citraFiltering.Image,(Bitmap)pfRobert.Image).ToString();

textBoxr5.Text

= hitungPSNR(Convert.ToDouble(textBoxr4.Text)).ToString(); }

void SaveroberClick(object sender, EventArgs e) {

if(pRobert.Image != null) {

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {

pRobert.Image.Save(save.FileName, System.Drawing.Imag ing.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

void SaveSobelClick(object sender, EventArgs e) {

if(pSobel.Image != null) {

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {


(14)

ng.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

void SavePrewittClick(object sender, EventArgs e) {

if(pPrewitt.Image != null) {

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {

pPrewitt.Image.Save(save.FileName, System.Drawing .Imaging.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

void SfSobelClick(object sender, EventArgs e) {

if(pfSobel.Image != null) {

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {

pfSobel.Image.Save(save.FileName, System.Drawing. Imaging.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

void SfPrewittClick(object sender, EventArgs e) {


(15)

{

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {

pfPrewitt.Image.Save(save.FileName, System.Drawin g.Imaging.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

double hitungMSE(Bitmap imageAsli, Bitmap imageHasil) {

double sum = 0; double pxAsli; double pxHasil; double MSE;

for (int i = 0; i < imageAsli.Height; i++) {

for (int j = 0; j < imageAsli.Width; j++) {

pxAsli = imageAsli.GetPixel(j, i).R; pxHasil = imageHasil.GetPixel(j, i).R; sum += Math.Pow(pxAsli - pxHasil, 2); }

}

MSE = sum / (imageAsli.Height * imageAsli.Width); return MSE;

}

double hitungPSNR (double MSE) {

double PSNR = Math.Log10(Math.Pow(255, 2)/MSE); return PSNR;

}

void PrewittClick(object sender, EventArgs e) {

Stopwatch time = new Stopwatch(); time.Start();

Bitmap bit = new Bitmap(citraAsli.Image); int x = bit.Height; int y = bit.Width; double rd=0,bl=0,gr=0,gy=0;

Bitmap imageHasil = new Bitmap(x,y); for (int i = 0; i < x-1; i++)

{

for (int j = 0; j <= y-1; j++) {


(16)

if (rd <=0) rd = 255;

gr = bit.GetPixel(i,j).G; bl = bit.GetPixel(i,j).B;

gy = (rd*0.3 + gr*0.59 + bl*0.11);

imageHasil.SetPixel(i,j,Color.FromArgb((int)gy,(int)gy,(i nt)gy));

gy = 0; }

}

pPrewitt.Image=PrewittEdgeDetect(imageHasil); time.Stop();

textBoxp3.Text =

Math.Round(Convert.ToDecimal(time.ElapsedMilliseconds)/1000,4).ToString(); textBoxp1.Text

= hitungMSE((Bitmap)citraAsli.Image,(Bitmap)pPrewitt.Image).ToString();

textBoxp2.Text

= hitungPSNR(Convert.ToDouble(textBoxp1.Text)).ToString(); }

void SobelClick(object sender, EventArgs e) {

Stopwatch time = new Stopwatch(); time.Start();

Bitmap bit = new Bitmap(citraAsli.Image); int x = bit.Height; int y = bit.Width; double rd=0,bl=0,gr=0,gy=0;

Bitmap imageHasil = new Bitmap(x,y); for (int i = 0; i < x-1; i++)

{

for (int j = 0; j <= y-1; j++) {

rd = bit.GetPixel(i,j).R; if (rd <=0)

rd = 255;

gr = bit.GetPixel(i,j).G; bl = bit.GetPixel(i,j).B;

gy = (rd*0.3 + gr*0.59 + bl*0.11);

imageHasil.SetPixel(i,j,Color.FromArgb((int)gy,(int)gy,(i nt)gy));

gy = 0; }

}

pSobel.Image=SobelEdgeDetect(imageHasil); time.Stop();

textBoxs3.Text =

Math.Round(Convert.ToDecimal(time.ElapsedMilliseconds)/1000,4).ToString(); textBoxs1.Text

= hitungMSE((Bitmap)citraAsli.Image,(Bitmap)pSobel.Image).ToString(); textBoxs2.Text

= hitungPSNR(Convert.ToDouble(textBoxs1.Text)).ToString(); }

void Button1Click(object sender, EventArgs e) {


(17)

{

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {

pSobel.Image.Save(save.FileName, System.Drawing.Imagi ng.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

void SobelFilterClick(object sender, EventArgs e) {

Stopwatch time = new Stopwatch(); time.Start();

Bitmap bit = new Bitmap(citraFiltering.Image); int x = bit.Height; int y = bit.Width;

double rd=0,bl=0,gr=0,gy=0;

Bitmap imageHasil = new Bitmap(x,y); for (int i = 0; i < x-1; i++)

{

for (int j = 0; j <= y-1; j++) {

rd = bit.GetPixel(i,j).R; if (rd <=0)

rd = 255;

gr = bit.GetPixel(i,j).G; bl = bit.GetPixel(i,j).B;

gy = (rd*0.3 + gr*0.59 + bl*0.11);

imageHasil.SetPixel(i,j,Color.FromArgb((int)gy,(int)gy,(i nt)gy));

gy = 0; }

}

pfSobel.Image=SobelEdgeDetect(imageHasil); time.Stop();

textBoxs6.Text =

Math.Round(Convert.ToDecimal(time.ElapsedMilliseconds)/1000,4).ToString(); textBoxs4.Text

= hitungMSE((Bitmap)citraFiltering.Image,(Bitmap)pfSobel.Image).ToString(); textBoxs5.Text

= hitungPSNR(Convert.ToDouble(textBoxs4.Text)).ToString(); }

void PrewittFilterClick(object sender, EventArgs e) {

Stopwatch time = new Stopwatch(); time.Start();

Bitmap bit = new Bitmap(citraFiltering.Image); int x = bit.Height; int y = bit.Width;


(18)

double rd=0,bl=0,gr=0,gy=0;

Bitmap imageHasil = new Bitmap(x,y); for (int i = 0; i < x-1; i++)

{

for (int j = 0; j <= y-1; j++) {

rd = bit.GetPixel(i,j).R; if (rd <=0)

rd = 255;

gr = bit.GetPixel(i,j).G; bl = bit.GetPixel(i,j).B;

gy = (rd*0.3 + gr*0.59 + bl*0.11);

imageHasil.SetPixel(i,j,Color.FromArgb((int)gy,(int)gy,(i nt)gy));

gy = 0; }

}

pfPrewitt.Image=PrewittEdgeDetect(imageHasil); time.Stop();

textBoxp6.Text =

Math.Round(Convert.ToDecimal(time.ElapsedMilliseconds)/1000,4).ToString(); textBoxp4.Text

= hitungMSE((Bitmap)citraFiltering.Image,(Bitmap)pfPrewitt.Image).ToString();

textBoxp5.Text

= hitungPSNR(Convert.ToDouble(textBoxp4.Text)).ToString(); }

void SfrobertClick(object sender, EventArgs e) {

if(pfRobert.Image != null) {

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {

pfRobert.Image.Save(save.FileName, System.Drawing.Ima ging.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

void SaveRobertClick(object sender, EventArgs e) {

Stopwatch time = new Stopwatch(); time.Start();

Bitmap bit = new Bitmap(citraAsli.Image); int x = bit.Height; int y = bit.Width; double rd=0,bl=0,gr=0,gy=0;


(19)

for (int i = 0; i < x-1; i++) {

for (int j = 0; j <= y-1; j++) {

rd = bit.GetPixel(i,j).R; if (rd <=0)

rd = 255;

gr = bit.GetPixel(i,j).G; bl = bit.GetPixel(i,j).B;

gy = (rd*0.3 + gr*0.59 + bl*0.11);

imageHasil.SetPixel(i,j,Color.FromArgb((int)gy,(int)gy,(i nt)gy));

gy = 0; }

}

pRobert.Image=RobertEdgeDetect(imageHasil); time.Stop();

textBoxr3.Text =

Math.Round(Convert.ToDecimal(time.ElapsedMilliseconds)/1000,4).ToString(); textBoxr1.Text

= hitungMSE((Bitmap)citraAsli.Image,(Bitmap)pRobert.Image).ToString(); textBoxr2.Text

= hitungPSNR(Convert.ToDouble(textBoxr1.Text)).ToString(); }

} }

4. Help.cs

namespace AnalisisPerbandinganFilertingdanDeteksiTepi {

public partial class Help : Form {

public Help() {

InitializeComponent(); }

void HomeToolStripMenuItemClick(object sender, EventArgs e) {

MainForm a = new MainForm(); this.Hide();

a.ShowDialog (); }

void FilteringToolStripMenuItemClick(object sender, EventArgs e) {

Filtering a = new Filtering(); this.Hide();

a.ShowDialog(); }


(20)

{

DeteksiTepi a = new DeteksiTepi(); this.Hide();

a.ShowDialog(); }

void AboutToolStripMenuItem1Click(object sender, EventArgs e) {

About a = new About(); this.Hide();

a.ShowDialog(); }

void ExitToolStripMenuItemClick(object sender, EventArgs e) {

if (MessageBox.Show("Are you sure to exit the

Aplication?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

Application.Exit(); }

} }

5. About.cs

using System;

using System.Drawing;

using System.Windows.Forms;

namespace AnalisisPerbandinganFilertingdanDeteksiTepi {

public partial class About : Form {

public About() {

InitializeComponent(); }

void HomeToolStripMenuItemClick(object sender, EventArgs e) {

MainForm a = new MainForm(); this.Hide();

a.ShowDialog (); }

void FilteringToolStripMenuItemClick(object sender, EventArgs e) {

Filtering a = new Filtering(); this.Hide();

a.ShowDialog(); }


(21)

void DeteksiTepiToolStripMenuItemClick(object sender, EventArgs e) {

DeteksiTepi a = new DeteksiTepi(); this.Hide();

a.ShowDialog(); }

void AboutToolStripMenuItemClick(object sender, EventArgs e) {

Help a = new Help(); this.Hide();

a.ShowDialog(); }

void ExitToolStripMenuItemClick(object sender, EventArgs e) {

if (MessageBox.Show("Are you sure to exit the

Aplication?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

Application.Exit(); }

} }


(22)

CURRICULUM VITAE

Nama

: Magdalena Refini Waty Siregar

Alamat Sekarang

: Jln. Bawang 8 No. 4, P.Simalingkar, Medan

Alamat Orang Tua

: Jln. Bawang 8 No. 4, P.Simalingkar, Medan

Telp/ Hp

: 082168415352

Email

: magdalena.siregar93@gmail.com

Riwayat Pendidikan

2011

2015

: S-1 Ilmu Komputer Universitas Sumatera Utara, Medan

2008

2011

: SMA Negeri 5, Medan

2005

2008

: SMP Negeri 2, Medan

2004

2005

: SD Negeri 068001, Medan

1999

2004

: SD Swasta Timbul Jaya Medan

Keahlian

Bahasa

: Indonesia, Inggris

Bahasa Pemrograman : C#, MATLAB

Database

: MySql

Design

: Photoshop, Corel Draw

Pengalaman Organisasi

[2009

2010]

Anggota PMR SMA Negeri 5 Medan

[2012-Sekarang]

Anggota GSKM HKBP P. Simalingkar, Medan

[2012

2013]

Anggota Kerohanian KMKI 2013

2014

[2012

2014]

Anggota Kominfo IMILKOM 2012 - 2014

[2014

2015]

Kepala Bidang Kominfo IMILKOM 2014

2015


(23)

Pengalaman Kepanitiaan

[2012]

Ketua Bidang Kesehatan PORSENI IMILKOM 2012

[2012]

Bendahara Natal S1 ILKOMP 2012

[2012]

Ketua Seksi Kesehatan Porseni IMILKOM 2012

[2013]

Wakil Sekretaris Acara PMB IMILKOM 2013

[2014]

Bendahara PMB Fasilkom-TI 2014

[2014]

Bendahara Pelaksana Natal Oikumene USU 2014

[2015]

Bendahara Pelaksana Paskah Oikumene USU 2015


(1)

double rd=0,bl=0,gr=0,gy=0;

Bitmap imageHasil = new Bitmap(x,y); for (int i = 0; i < x-1; i++)

{

for (int j = 0; j <= y-1; j++) {

rd = bit.GetPixel(i,j).R; if (rd <=0)

rd = 255;

gr = bit.GetPixel(i,j).G; bl = bit.GetPixel(i,j).B;

gy = (rd*0.3 + gr*0.59 + bl*0.11);

imageHasil.SetPixel(i,j,Color.FromArgb((int)gy,(int)gy,(i nt)gy));

gy = 0; } } pfPrewitt.Image=PrewittEdgeDetect(imageHasil); time.Stop(); textBoxp6.Text = Math.Round(Convert.ToDecimal(time.ElapsedMilliseconds)/1000,4).ToString(); textBoxp4.Text = hitungMSE((Bitmap)citraFiltering.Image,(Bitmap)pfPrewitt.Image).ToString(); textBoxp5.Text = hitungPSNR(Convert.ToDouble(textBoxp4.Text)).ToString(); }

void SfrobertClick(object sender, EventArgs e) {

if(pfRobert.Image != null) {

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files | *.bmp";

save.FileName = "*.bmp";

if (save.ShowDialog() == DialogResult.OK) {

pfRobert.Image.Save(save.FileName, System.Drawing.Ima ging.ImageFormat.Bmp);

MessageBox.Show("image save

!", "save", MessageBoxButtons.OK, MessageBoxIcon.Information); }

else {

MessageBox.Show("error save !"); }

} }

void SaveRobertClick(object sender, EventArgs e) {

Stopwatch time = new Stopwatch(); time.Start();

Bitmap bit = new Bitmap(citraAsli.Image); int x = bit.Height; int y = bit.Width; double rd=0,bl=0,gr=0,gy=0;


(2)

for (int i = 0; i < x-1; i++) {

for (int j = 0; j <= y-1; j++) {

rd = bit.GetPixel(i,j).R; if (rd <=0)

rd = 255;

gr = bit.GetPixel(i,j).G; bl = bit.GetPixel(i,j).B;

gy = (rd*0.3 + gr*0.59 + bl*0.11);

imageHasil.SetPixel(i,j,Color.FromArgb((int)gy,(int)gy,(i nt)gy));

gy = 0; }

}

pRobert.Image=RobertEdgeDetect(imageHasil); time.Stop();

textBoxr3.Text =

Math.Round(Convert.ToDecimal(time.ElapsedMilliseconds)/1000,4).ToString(); textBoxr1.Text

= hitungMSE((Bitmap)citraAsli.Image,(Bitmap)pRobert.Image).ToString(); textBoxr2.Text

= hitungPSNR(Convert.ToDouble(textBoxr1.Text)).ToString(); }

} }

4. Help.cs

namespace AnalisisPerbandinganFilertingdanDeteksiTepi {

public partial class Help : Form {

public Help() {

InitializeComponent(); }

void HomeToolStripMenuItemClick(object sender, EventArgs e) {

MainForm a = new MainForm(); this.Hide();

a.ShowDialog (); }

void FilteringToolStripMenuItemClick(object sender, EventArgs e) {

Filtering a = new Filtering(); this.Hide();

a.ShowDialog(); }


(3)

{

DeteksiTepi a = new DeteksiTepi(); this.Hide();

a.ShowDialog(); }

void AboutToolStripMenuItem1Click(object sender, EventArgs e) {

About a = new About(); this.Hide();

a.ShowDialog(); }

void ExitToolStripMenuItemClick(object sender, EventArgs e) {

if (MessageBox.Show("Are you sure to exit the

Aplication?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

Application.Exit(); }

} }

5. About.cs

using System;

using System.Drawing;

using System.Windows.Forms;

namespace AnalisisPerbandinganFilertingdanDeteksiTepi {

public partial class About : Form {

public About() {

InitializeComponent(); }

void HomeToolStripMenuItemClick(object sender, EventArgs e) {

MainForm a = new MainForm(); this.Hide();

a.ShowDialog (); }

void FilteringToolStripMenuItemClick(object sender, EventArgs e) {

Filtering a = new Filtering(); this.Hide();

a.ShowDialog(); }


(4)

void DeteksiTepiToolStripMenuItemClick(object sender, EventArgs e) {

DeteksiTepi a = new DeteksiTepi(); this.Hide();

a.ShowDialog(); }

void AboutToolStripMenuItemClick(object sender, EventArgs e) {

Help a = new Help(); this.Hide();

a.ShowDialog(); }

void ExitToolStripMenuItemClick(object sender, EventArgs e) {

if (MessageBox.Show("Are you sure to exit the

Aplication?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

Application.Exit(); }

} }


(5)

CURRICULUM VITAE

Nama

: Magdalena Refini Waty Siregar

Alamat Sekarang

: Jln. Bawang 8 No. 4, P.Simalingkar, Medan

Alamat Orang Tua

: Jln. Bawang 8 No. 4, P.Simalingkar, Medan

Telp/ Hp

: 082168415352

Email

: magdalena.siregar93@gmail.com

Riwayat Pendidikan

2011

2015

: S-1 Ilmu Komputer Universitas Sumatera Utara, Medan

2008

2011

: SMA Negeri 5, Medan

2005

2008

: SMP Negeri 2, Medan

2004

2005

: SD Negeri 068001, Medan

1999

2004

: SD Swasta Timbul Jaya Medan

Keahlian

Bahasa

: Indonesia, Inggris

Bahasa Pemrograman : C#, MATLAB

Database

: MySql

Design

: Photoshop, Corel Draw

Pengalaman Organisasi

[2009

2010]

Anggota PMR SMA Negeri 5 Medan

[2012-Sekarang]

Anggota GSKM HKBP P. Simalingkar, Medan

[2012

2013]

Anggota Kerohanian KMKI 2013

2014

[2012

2014]

Anggota Kominfo IMILKOM 2012 - 2014

[2014

2015]

Kepala Bidang Kominfo IMILKOM 2014

2015


(6)

Pengalaman Kepanitiaan

[2012]

Ketua Bidang Kesehatan PORSENI IMILKOM 2012

[2012]

Bendahara Natal S1 ILKOMP 2012

[2012]

Ketua Seksi Kesehatan Porseni IMILKOM 2012

[2013]

Wakil Sekretaris Acara PMB IMILKOM 2013

[2014]

Bendahara PMB Fasilkom-TI 2014

[2014]

Bendahara Pelaksana Natal Oikumene USU 2014

[2015]

Bendahara Pelaksana Paskah Oikumene USU 2015