Professional Documents
Culture Documents
Appendix
Appendix
using System;
using System.Collections;
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;
namespace Order_Statistic_Filters
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
if (DialogResult.OK == openFileDialog.ShowDialog())
{
Bitmap aa = new Bitmap(openFileDialog.FileName);
citraAsli.Image = aa;
if (DialogResult.OK == saveFileDialog.ShowDialog())
{
citra.Save(saveFileDialog.FileName);
MessageBox.Show("File Hasil Filter disimpan.");
}
if (citraHasil==null)
{
simpanGambarToolStripMenuItem.Enabled = false;
}
}
temp[b, 0] = sem[0];
temp[b, 1] = sem[1];
temp[b, 2] = sem[2];
}
}
}
hasil.SetPixel(i, j, Color.FromArgb
(255, temp[4, 2], temp[4, 1], temp[4, 0]));
}
}
return hasil;
}
temp[b, 0] = sem[0];
temp[b, 1] = sem[1];
temp[b, 2] = sem[2];
}
}
}
hasil.SetPixel(i, j, Color.FromArgb
(255, temp[8, 2], temp[8, 1], temp[8, 0]));
temp[b, 0] = sem[0];
temp[b, 1] = sem[1];
temp[b, 2] = sem[2];
}
}
}
hasil.SetPixel(i, j, Color.FromArgb
(255, temp[0, 2], temp[0, 1], temp[0, 0]));
}
}
return hasil;
}
temp[b, 0] = sem[0];
temp[b, 1] = sem[1];
temp[b, 2] = sem[2];
}
}
}
hasil.SetPixel(i, j, Color.FromArgb
(255, (byte)((temp[8, 2] + temp[0, 2]) / 2),
(byte)((temp[8, 1] + temp[0, 1]) / 2),
}
}
return hasil;
}
using System;
using System.Collections;
using System.Collections.Generic;
namespace Order_Statistic_Filters
{
public partial class Form9 : Form
{
public Form9()
{
InitializeComponent();
}
if (DialogResult.OK == openFileDialog.ShowDialog())
{
Bitmap aa = new Bitmap(openFileDialog.FileName);
citraAsli.Image = aa;
button2.Enabled = true;
}
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = " ";
openFileDialog.Filter = "Bitmap files (*.bmp)|*.bmp";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;
if (DialogResult.OK == openFileDialog.ShowDialog())
{
Bitmap aa = new Bitmap(openFileDialog.FileName);
HasilMedian.Image = aa;
button3.Enabled = true;
}
}
a2 = data_citraHasil.GetPixel(i, j).R;
b2 = data_citraHasil.GetPixel(i, j).G;
c2 = data_citraHasil.GetPixel(i, j).B;
temp1 = a1 - a2;
temp2 = b1 - b2;
temp3 = c1 - c2;
if (temp1 < 0)
temp1 = temp1 * (-1);
if (temp2 < 0)
temp2 = temp2 * (-1);
if (temp3 < 0)
temp3 = temp3 * (-1);
nilai_mse += temp4;
}
}
nilai_mse = nilai_mse / (data_citraAsli.Width * data_citraAsli.Height);
textBox1.Text = nilai_mse.ToString();
}
else
{
MessageBox.Show("Resolusi citra yang di input harus sama !");
}
{
{
double result, cross;
cross = (10 * 255) / Math.Sqrt(nilai_mse);
result = Math.Log(cross, 20);
textBox2.Text = result.ToString();
}
}
}
catch { }
try
aa = data_mean.GetPixel(i, j).R;
bb = data_mean.GetPixel(i, j).G;
cc = data_mean.GetPixel(i, j).B;
tempa = a - aa;
tempb = b - bb;
tempc = c - cc;
if (tempa < 0)
tempa = tempa * (-1);
if (tempb < 0)
tempb = tempb * (-1);
if (tempc < 0)
tempc = tempc * (-1);
textBox3.Text = nilai_mseMean.ToString();
}
else
{
MessageBox.Show("Resolusi citra yang di input harus sama !");
}
{
{
double hasil, kali;
kali = (10 * 255) / Math.Sqrt(nilai_mseMean);
hasil = Math.Log(kali, 20);
textBox4.Text = hasil.ToString();
}
}
catch{}
ee = data_max.GetPixel(i, j).R;
ff = data_max.GetPixel(i, j).G;
gg = data_max.GetPixel(i, j).B;
tempe = ei - ee;
tempf = f - ff;
tempg = g - gg;
if (tempe < 0)
tempe = tempe * (-1);
if (tempf < 0)
tempf = tempf * (-1);
if (tempg < 0)
tempg = tempg * (-1);
textBox5.Text = nilai_mseMax.ToString();
}
else
{
MessageBox.Show("Resolusi citra yang di input harus sama !");
}
k = data_citraAsli3.GetPixel(i, j).R;
l = data_citraAsli3.GetPixel(i, j).G;
m = data_citraAsli3.GetPixel(i, j).B;
kk = data_HasilMin.GetPixel(i, j).R;
ll = data_HasilMin.GetPixel(i, j).G;
mm = data_HasilMin.GetPixel(i, j).B;
tempk = k - kk;
templ = l - ll;
tempm = m - mm;
if (tempk < 0)
tempk = tempk * (-1);
if (templ < 0)
templ = templ * (-1);
if (tempm < 0)
tempm = tempm * (-1);
textBox7.Text = nilai_mseMin.ToString();
else
{
MessageBox.Show("Resolusi citra yang di input harus sama !");
{
{
double results, crossx;
crossx = (10 * 255) / Math.Sqrt(nilai_mseMin);
results = Math.Log(crossx, 20);
textBox8.Text = results.ToString();
}
}
}
catch { }
p = data_citraAsli4.GetPixel(i, j).R;
q = data_citraAsli4.GetPixel(i, j).G;
r = data_citraAsli4.GetPixel(i, j).B;
p2 = data_HasilMid.GetPixel(i, j).R;
q2 = data_HasilMid.GetPixel(i, j).G;
r2 = data_HasilMid.GetPixel(i, j).B;
tempp = p - p2;
tempq = q - q2;
tempr = r - r2;
if (tempp < 0)
tempp = tempp * (-1);
if (tempq < 0)
tempq = tempq * (-1);
if (tempr < 0)
tempr = tempr * (-1);
textBox9.Text = nilai_mseMidpoint.ToString();
}
else
{
MessageBox.Show("Resolusi citra yang di input harus sama !");
}
{
{
double hasils, kalis;
kalis = (10 * 255) / Math.Sqrt(nilai_mseMidpoint);
hasils = Math.Log(kalis, 20);
textBox10.Text = hasils.ToString();
}
MessageBox.Show("Perhitungan MSE & PSNR berhasil");
}
}
catch { }
}
if (DialogResult.OK == openFileDialog.ShowDialog())
{
Bitmap aa = new Bitmap(openFileDialog.FileName);
HasilMean.Image = aa;
}
private void button6_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = " ";
openFileDialog.Filter = "Bitmap files (*.bmp)|*.bmp";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;
if (DialogResult.OK == openFileDialog.ShowDialog())
{
Bitmap aa = new Bitmap(openFileDialog.FileName);
if (DialogResult.OK == openFileDialog.ShowDialog())
{
Bitmap aa = new Bitmap(openFileDialog.FileName);
HasilMin.Image = aa;
}
}
private void button8_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = " ";
openFileDialog.Filter = "Bitmap files (*.bmp)|*.bmp";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;
if (DialogResult.OK == openFileDialog.ShowDialog())
{
Bitmap aa = new Bitmap(openFileDialog.FileName);
HasilMidpoint.Image = aa;
}
}
}
}
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 Order_Statistic_Filters
{
public partial class Form7 : Form
{
public Form7()
{
InitializeComponent();
}
y = citra.Height;
x = citra.Width;
prob = Convert.ToInt32(persen.Text);
}
else
{
prob = Convert.ToInt32(x * y * prob * 0.01);
Random rand = new Random();
for (i = 0; i < prob; i++)
{
x1 = rand.Next(0, x - 1);
y1 = rand.Next(0, y - 1);
pilih = rand.Next(1,10);
if (pilih <=5)
{
citra.SetPixel(x1, y1, Color.FromArgb(255, 0, 0, 0));
}
else
{
citra.SetPixel(x1, y1, Color.FromArgb(255, 255, 255, 255));
}
}
Gambar.Image = citra;
button3.Enabled = true;
MessageBox.Show("Prosess Pembangkitan Noise Berhasil");
}
}
catch
{
MessageBox.Show("Pastikan inputan probabilitas noisenya benar!");
}
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = " ";
openFileDialog.Filter = "Bitmap files (*.bmp)|*.bmp";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;
if (DialogResult.OK == openFileDialog.ShowDialog())
{
Bitmap aa = new Bitmap(openFileDialog.FileName);
Gambar.Image = aa;
persen.Enabled = true;
}
}
private void button3_Click(object sender, EventArgs e)
{
Bitmap citra = new Bitmap((Bitmap)this.Gambar.Image);
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.InitialDirectory = " ";
if (DialogResult.OK == saveFileDialog.ShowDialog())
{
citra.Save(saveFileDialog.FileName);
MessageBox.Show("Hasil Penambahan Noise pada citra berhasil disimpan.");
}
button4.Enabled = true;
}
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;
namespace Order_Statistic_Filters
{
public class RestorasiCitra
{
Bitmap citra = null;
IntPtr Iptr = IntPtr.Zero;
BitmapData bmpData = null;
GaussianRandom gaussgen = new GaussianRandom();