LISTING PROGRAM Kode Program Menu Utama: using System;

  LISTING PROGRAM Kode Program Menu Utama:

  using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Harmonic_Mean_Filter { public partial class utama : Form { public utama() { InitializeComponent(); } private void tambahNoiseToolStripMenuItem_Click(object sender, EventArgs e) { tambahnoise frm2 = new tambahnoise(); this.Dispose(); frm2.ShowDialog(); } private void keluarToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("Apakah Anda Ingin Keluar Aplikasi?", "Keluar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Application.Exit(); } } private void pengujianToolStripMenuItem_Click(object sender, EventArgs e) { Form3 frm3 = new Form3(); this.Dispose(); frm3.ShowDialog(); } private void tentangToolStripMenuItem_Click(object sender, EventArgs e) { tentang frm5 = new tentang(); this.Dispose(); frm5.ShowDialog(); } private void bantuanToolStripMenuItem_Click(object sender, EventArgs e) { bantuan frm4 = new bantuan(); this.Dispose(); frm4.ShowDialog(); } private void label7_Click(object sender, EventArgs e) { } private void utama_Load(object sender, EventArgs e) { } private void label2_Click(object sender, EventArgs e) { } private void pictureBox1_Click(object sender, EventArgs e) { } } }

  Kode Program Menu Tambah Noise:

  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.IO; using System.Diagnostics; using System.Runtime.InteropServices; namespace Harmonic_Mean_Filter { public partial class tambahnoise : Form { BitmapData bmpData = null; byte[] Pixels; IntPtr point = IntPtr.Zero; private bool bitdeviasi; private double Deviasi; string JenisNoise = ""; public tambahnoise() { InitializeComponent(); } private void button6_Click(object sender, EventArgs e) { utama frm1 = new utama(); this.Dispose(); frm1.ShowDialog(); } private void button1_Click(object sender, EventArgs e) { try { OpenFileDialog open = new OpenFileDialog(); open.Filter = "Image Files(*.bmp)|*.bmp|Image Files(*.jpg)|*.jpg|All Files(*.*)|*.*"; if (open.ShowDialog() == DialogResult.OK) { Bitmap bit = new Bitmap(open.FileName); citraawal.Image = bit; long fileSize = new System.IO.FileInfo(open.FileName).Length; if (fileSize / 1000 < 1) { size.Text = fileSize.ToString(); lblSize.Text = "Byte"; } else { size.Text = (fileSize / 1000).ToString(); lblSize.Text = "Kb"; }

location.Text = Path.GetFullPath(open.FileName); filename.Text = Path.GetFileName(open.FileName); height.Text = bit.Height.ToString(); width.Text = bit.Width.ToString(); } } catch (Exception) { throw new ApplicationException("Failed loading image"); } } private void tambahnoise_Load(object sender, EventArgs e) { } private void button3_Click(object sender, EventArgs e) { Bitmap citra = new Bitmap(citraawal.Image); int x, y, widthPos, HeightPos, randomNumber; double prob; y = citra.Height; x = citra.Width; prob = Convert.ToDouble(textBox6.Text); if (prob > 100 || prob < 0) { MessageBox.Show("Input Noise hanya antara 0 - 100"); } else { prob = Convert.ToInt32(x * y * (prob/200)); Random rnd = new Random(); while (prob > 0) { widthPos = rnd.Next(0, x - 1); HeightPos = rnd.Next(0, y - 1); randomNumber = rnd.Next(1, 10); if (randomNumber <= 5) { citra.SetPixel(widthPos, HeightPos, Color.FromArgb(255, 0, 0, 0)); } else { citra.SetPixel(widthPos, HeightPos, Color.FromArgb(255, 255, 255, 255)); } prob--;

  } citranoise.Image = citra; button4.Enabled = true; button5.Enabled = true; MessageBox.Show("Noise Salt and Pepper telah berhasil ditambahkan"); JenisNoise = "Salt and Pepper Noise"; } } private void button4_Click(object sender, EventArgs e) { citranoise.Image = null; textBox6.Text = ""; button4.Enabled = false; button5.Enabled = false; } private void button5_Click(object sender, EventArgs e) { if (citranoise.Image != null) { SaveFileDialog simpan = new SaveFileDialog(); simpan.Filter = "Image Files|*.bmp|Image Files|*.png"; simpan.FileName = "*.bmp"; if (simpan.ShowDialog() == DialogResult.OK) { citranoise.Image.Save(simpan.FileName, System.Drawing.Imaging.ImageFormat.Bmp); string filename = simpan.FileName.Substring(0, simpan.FileName.Length - 4) + ".txt"; FileStream fstream = new FileStream(filename, FileMode.OpenOrCreate); StreamWriter sw = new StreamWriter(fstream); SeekOrigin seekorigin = new SeekOrigin(); sw.BaseStream.Seek(0, seekorigin); sw.WriteLine(textBox6.Text + "/" + JenisNoise); sw.Flush(); sw.Close(); MessageBox.Show("Citra Bernoise Telah Disimpan", "Simpan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Citra Bernoise Belum Ada"); }

  } private double getGaussianNumber() { Random rnd = new Random(); double v1, v2, persegi; if (bitdeviasi) { bitdeviasi = false; return Deviasi * 1; } do { // nilai random antara -1.0 and 1.0 v1 = 2 * rnd.NextDouble() - 1; v2 = 2 * rnd.NextDouble() - 1; persegi = v1 * v1 + v2 * v2; // untuk memastikan dalam satu cakupan } while (persegi >= 1 || persegi == 0); var kutup = Math.Sqrt(-2 * Math.Log(persegi) / persegi); // menyimpan simpangan pertama Deviasi = v2 * kutup; bitdeviasi = true; // return kembali ke simp[angan kedua return v1 * kutup; } private void button2_Click(object sender, EventArgs e) { Bitmap citra = new Bitmap(citraawal.Image); int x, y, PixelSize; double gaussnumber = 0.0; int step, newpixel; double prob; y = citra.Height; x = citra.Width; PixelSize = x * y; prob = Convert.ToInt32(textBox6.Text); if (prob > 100 || prob < 0) { MessageBox.Show("Input Noise hanya antara 0 - 100"); } else { Random rnd = new Random(); Rectangle box = new Rectangle(0, 0, x, y); int Depth = System.Drawing.Bitmap.GetPixelFormatSize(citra.PixelFormat); step = Depth / 8; bmpData = citra.LockBits(box, ImageLockMode.ReadWrite, citra.PixelFormat); Pixels = new byte[PixelSize * step]; point = bmpData.Scan0; Marshal.Copy(point, Pixels, 0, Pixels .Length); for (int i = 0; i < Pixels.Length; i+=step) { if (i < Pixels.Length - step) { for (int j = 0; j < step; j++) { gaussnumber = getGaussianNumber(); newpixel = Convert.ToInt32(gaussnumber * prob) + Convert.ToInt32(Pixels[i + j]); if (newpixel < 0) newpixel = 0; if (newpixel > 255) newpixel = 255; Pixels[i + j] = Convert.ToByte(newpixel); } } //i += step; } Marshal.Copy(Pixels, 0, point, Pixels.Length); citra.UnlockBits(bmpData); citranoise.Image = citra; button4.Enabled = true; button5.Enabled = true; MessageBox.Show("Noise Gaussian telah berhasil ditambahkan"); JenisNoise = "Gaussian Noise"; } } } }

  Kode Program Menu Reduksi Noise: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.IO; namespace Harmonic_Mean_Filter { public partial class Form3 : Form { Bitmap imageAwal, image, imagehasil; public Form3() { InitializeComponent(); } private void groupBox1_Enter(object sender, EventArgs e) { } private void label7_Click(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { imageAwal = new Bitmap(imgAwal.Image); Stopwatch sw = new Stopwatch(); sw.Start(); image = new Bitmap(redcitranoise.Image); int xi = image.Width; int yi = image.Height; double red = 0, green = 0, blue = 0, hasilred = 0, hasilgreen = 0, hasilblue = 0; double redfinal, greenfinal, bluefinal; imagehasil = new Bitmap(xi, yi); for (int i = 0; i < yi-2; i++) { for (int j = 0; j < xi-2; j++) { for (int k = i; k <= i + 2; k++) { for (int l = j; l <= j + 2; l++) { red = image.GetPixel(l, k).R; if (red == 0) red = 255; green = image.GetPixel(l, k).G; if (green == 0) green = 255; blue = image.GetPixel(l, k).B; if (blue == 0) blue = 255; hasilred += (1.0 / red); hasilgreen += (1.0 / green); hasilblue += (1.0 / blue); } } redfinal = 9/hasilred; double RED = Math.Round(redfinal, 0); greenfinal = 9/hasilgreen; double GREEN = Math.Round(greenfinal, 0); bluefinal = 9/hasilblue; double BLUE = Math.Round(bluefinal, 0); imagehasil.SetPixel(j + 1, i + 1, Color.FromArgb(255, (int)RED, (int)GREEN, (int)BLUE)); hasilred = 0;

hasilgreen = 0; hasilblue = 0; } } pictureBox1.Image = imagehasil; double MSENoise = hitungMSE(imageAwal, image); double MSE = hitungMSE(imageAwal, imagehasil); txtMSE.Text = MSE.ToString(); double persentase = 0; if (txtNoise.Text.CompareTo("Salt and Pepper Noise") > 0) persentase = ((MSENoise - MSE) / MSENoise) * Convert.ToInt32(txtPersentase.Text); else persentase = ((MSE - MSENoise) / MSE) * Convert.ToInt32(txtPersentase.Text); txtPersen.Text = persentase > 0 ? Math.Round(persentase).ToString() : "0"; txtPSNR.Text = hitungPSNR(MSE).ToString(); sw.Stop(); txtTime.Text = Math.Round(Convert.ToDecimal(sw.ElapsedMilliseconds) / 1000, 4).ToString(); MessageBox.Show("Proses Reduksi Noise Selesai"); } private void button1_Click(object sender, EventArgs e) { try { OpenFileDialog open = new OpenFileDialog(); open.Filter = "Image Files(*.bmp)|*.bmp|Image Files(*.png)|*.png|All Files(*.*)|*.*"; if (open.ShowDialog() == DialogResult.OK) { Bitmap bit = new Bitmap(open.FileName); redcitranoise.Image = bit; string nama = open.FileName.Substring(0, open.FileName.Length - 4) + ".txt"; FileStream fstream = new FileStream(nama, FileMode.Open, FileAccess.ReadWrite); StreamReader sreader = new StreamReader(fstream); sreader.BaseStream.Seek(0, SeekOrigin.Begin); string Keterangan = sreader.ReadToEnd(); sreader.Close(); string[] info = new string[2]; info = Keterangan.Split('/'); txtPersentase.Text = info[0]; txtNoise.Text = info[1]; } } catch (Exception) { throw new ApplicationException("Failed loading image"); } } private void button3_Click(object sender, EventArgs e) { redcitranoise.Image = null; }

private void button4_Click(object sender, EventArgs e) { if (pictureBox1.Image != null) { SaveFileDialog simpan = new SaveFileDialog(); simpan.Filter = "Image Files|*.bmp|Image Files|*.png"; simpan.FileName = "*.bmp"; if (simpan.ShowDialog() == DialogResult.OK) { pictureBox1.Image.Save(simpan.FileName, System.Drawing.Imaging.ImageFormat.Bmp); MessageBox.Show("Citra Hasil telah disimpan", "Simpan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Citra Hasil belum ada"); } } private void button5_Click(object sender, EventArgs e) { utama frm1 = new utama(); this.Dispose(); frm1.ShowDialog(); } private double hitungMSE(Bitmap imageAsli, Bitmap imageHasil) { double sum = 0; double r1, r2, g1, g2, b1, b2, MSE; for (int i = 0; i < imageAsli.Height; i++) { for (int j = 0; j < imageAsli.Width; j++) { r1 = imageAsli.GetPixel(j, i).R; r2 = imageHasil.GetPixel(j, i).R; sum += Math.Pow(r1 - r2, 2); g1 = imageAsli.GetPixel(j, i).G; g2 = imageHasil.GetPixel(j, i).G; sum += Math.Pow(g1 - g2, 2); b1 = imageAsli.GetPixel(j, i).B; b2 = imageHasil.GetPixel(j, i).B; sum += Math.Pow(b1 - b2, 2); } } MSE = sum / (imageAsli.Height * imageAsli.Width); return MSE; } private double hitungPSNR(double MSE) { double PSNR = Math.Log10(Math.Pow(255, 2) / MSE); return PSNR; } private void button6_Click(object sender, EventArgs e) {

try { OpenFileDialog open = new OpenFileDialog(); open.Filter = "Image Files(*.bmp)|*.bmp|Image Files(*.png)|*.png|All Files(*.*)|*.*"; if (open.ShowDialog() == DialogResult.OK) { Bitmap bit = new Bitmap(open.FileName); imgAwal.Image = bit; } } catch (Exception) { throw new ApplicationException("Failed loading image"); } } } } Kode Program Menu Bantuan:

  using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Harmonic_Mean_Filter { public partial class bantuan : Form { public bantuan() { InitializeComponent(); } private void kembali4_Click(object sender, EventArgs e) { utama frm1 = new utama(); this.Dispose(); frm1.ShowDialog(); } } }

  Kode Program Menu Tentang:

  using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Harmonic_Mean_Filter { public partial class tentang : Form { public tentang() { InitializeComponent(); } private void tentang_Load(object sender, EventArgs e) { } private void kembali5_Click(object sender, EventArgs e) { utama frm1 = new utama(); this.Dispose(); frm1.ShowDialog(); } } }

DAFTAR RIWAYAT HIDUP DATA PRIBADI

  Nama Lengkap : Gamal Nasir Jenis Kelamin : Laki-laki Tempat, Tanggal Lahir : Banda Aceh, 19 Juli 1992 Alamat : Jl. Binjai Km.10 Gang. Damai No.35 Deli Serdang Agama : Islam E-mail : gamalnasir1992@gmail.com Pendidikan Terakhir : Universitas Sumatera Utara Medan, Fakultas Ilmu Komputer dan Teknologi Informasi Jurusan S1

  Ilmu Komputer

PENDIDIKAN FORMAL

  2009 – 2014 : S1 Ilmu Komputer Universitas Sumatera Utara, Medan 2006 – 2009 : SMA Negeri 15 Medan 2003 – 2006 : SMP Negeri 19 Medan 1997 – 2003 : SD Negeri 101731 Deli Serdang

PENGALAMAN ORGANISASI DAN KEGIATAN ILMIAH

  Wakil Ketua OSIS SMP Negeri 19 Medan, 2004-2005

  

Wakil Ketua PIKIR (Pusat Informasi Reproduksi dan Gender) SMA Negeri 15

   Medan 2006-2009 Anggota OSIS SMA Negeri 15 Medan 2007-2009

  

Anggota Departemen Hubungan Humas Ikatan Mahasiswa S1 Ilmu Komputer

 (IMILKOM), 2009-2011 Ketua PORSENI (Pekan Olahraga dan Seni) IMILKOM, 2010-2011

   Anggota PEMA Fakultas MIPA 2010-2011 

   Ketua Outbond PMB IMILKOM 2011-2012

   Anggota PMB PEMA FASILKOM-TI 2012-2013

  

Ketua Departemen Hubungan Masyarakat Ikatan Mahasiswa S1 Ilmu

Komputer (IMILKOM), 2012-2013

  

Praktek Kerja Lapangan DISPENDA PROVSU (Dinas Pendapatan Daerah

Provinsi Sumatera Utara) Juli-Agustus 2012