2. Form Implementasi ONF dan BRF
using System; using System.Collections.Generic;
using System.ComponentModel; using System.Data;
using System.Drawing; using System.Linq;
using System.Text; using System.Threading.Tasks;
using System.Windows.Forms; namespace SelectiveFilter2
{ public partial class Form5 : Form
{ FFT ImgFFT;
public Form5 {
InitializeComponent; }
private void button1_Clickobject sender, EventArgs e {
DateTime satu, dua; double W, D0, n;
if W1.Text = || D01.Text = || n1.Text = {
try {
W = Convert.ToDoubleW1.Text; D0 = Convert.ToDoubleD01.Text;
n = Convert.ToDoublen1.Text; Bitmap Is3 = new
BitmapBitmapthis.citraAbu.Image; ImgFFT = new FFTIs3;
satu = DateTime.Now; ImgFFT.ForwardFFT;
ImgFFT.FFTShift; ImgFFT.FFTPlotImgFFT.FFTShifted;
citraSpektrum.Image = ImageImgFFT.FourierPlot; ImgFFT.RemoveFFTShift;
double[,] a = new double[ImgFFT.Obj.Width, ImgFFT.Obj.Height];
selectiveFilter.Band_Rejecta, W, D0, ImgFFT.Obj.Width, ImgFFT.Obj.Height, 1, intn;
for int p = 0; p 5; p++ {
for int v = 0; v ImgFFT.Obj.Height; v++ {
for int u = 0; u ImgFFT.Obj.Width; u++
{
Universitas Sumatera Utara
ImgFFT.FFTNormal[u, v].real = a[u, v];
ImgFFT.Output[u, v].real = ImgFFT.FFTNormal[u, v].real;
ImgFFT.FFTNormal[u, v].imag = a[u, v];
ImgFFT.Output[u, v].imag = ImgFFT.FFTNormal[u, v].imag;
} }
} ImgFFT.RemoveFFTShift;
ImgFFT.InverseFFT; dua = DateTime.Now;
TimeSpan seli = dua.Subtractsatu; BR_ideal.Image = ImageImgFFT.Obj;
satu = DateTime.Now; ImgFFT = new FFTIs3;
ImgFFT.ForwardFFT; ImgFFT.FFTShift;
ImgFFT.FFTPlotImgFFT.FFTShifted; citraSpektrum.Image = ImageImgFFT.FourierPlot;
ImgFFT.RemoveFFTShift; selectiveFilter.Band_Rejecta, W, D0,
ImgFFT.Obj.Width, ImgFFT.Obj.Height, 2, intn; for int p = 0; p 1; p++
{ for int v = 0; v ImgFFT.Obj.Height; v++
{ for int u = 0; u ImgFFT.Obj.Width;
u++ {
ImgFFT.FFTNormal[u, v].real = a[u, v];
ImgFFT.Output[u, v].real = ImgFFT.FFTNormal[u, v].real;
ImgFFT.FFTNormal[u, v].imag = a[u, v];
ImgFFT.Output[u, v].imag = ImgFFT.FFTNormal[u, v].imag;
} }
} ImgFFT.RemoveFFTShift;
ImgFFT.InverseFFT; dua = DateTime.Now;
BR_B.Image = ImageImgFFT.Obj; satu = DateTime.Now;
Universitas Sumatera Utara
ImgFFT = new FFTIs3; ImgFFT.ForwardFFT;
ImgFFT.FFTShift; ImgFFT.FFTPlotImgFFT.FFTShifted;
citraSpektrum.Image = ImageImgFFT.FourierPlot; ImgFFT.RemoveFFTShift;
selectiveFilter.Band_Rejecta, W, D0, ImgFFT.Obj.Width, ImgFFT.Obj.Height, 3, intn;
for int p = 0; p 8; p++ {
for int v = 0; v ImgFFT.Obj.Height; v++ {
for int u = 0; u ImgFFT.Obj.Width; u++
{ ImgFFT.FFTNormal[u, v].real = a[u,
v]; ImgFFT.Output[u, v].real =
ImgFFT.FFTNormal[u, v].real; ImgFFT.FFTNormal[u, v].imag = a[u,
v]; ImgFFT.Output[u, v].imag =
ImgFFT.FFTNormal[u, v].imag; }
} }
ImgFFT.RemoveFFTShift; ImgFFT.InverseFFT;
dua = DateTime.Now; BR_G.Image = ImageImgFFT.Obj;
MessageBox.ShowProses Filter selesai, tekan tombol simpan untuk menyimpan gambar, Sukses,
MessageBoxButtons.OK, MessageBoxIcon.Information; }
catch Exception ex {
MessageBox.ShowMasukkan angka, bukan Huruf, GAGAL, MessageBoxButtons.OK, MessageBoxIcon.Error;
} }
} private void button2_Clickobject sender, EventArgs e
{ double D0, n;
DateTime satu, dua; int x1x, x2x, y1y, y2y;
if DO2.Text = || n2.Text = || x1.Text = || x2.Text = || y1.Text = || y2.Text =
{ try
{ D0 = Convert.ToDoubleDO2.Text;
n = Convert.ToDoublen2.Text;
Universitas Sumatera Utara
x1x = Convert.ToInt32x1.Text; x2x = Convert.ToInt32x2.Text;
y1y = Convert.ToInt32y1.Text; y2y = Convert.ToInt32y2.Text;
Bitmap Is3 = new BitmapBitmapthis.citraAbu.Image;
satu = DateTime.Now; ImgFFT = new FFTIs3;
ImgFFT.ForwardFFT; ImgFFT.FFTShift;
ImgFFT.FFTPlotImgFFT.FFTShifted; citraSpektrum.Image = ImageImgFFT.FourierPlot;
double[,] a = new double[ImgFFT.Obj.Width, ImgFFT.Obj.Height];
int[,] K = { { x1x, y1y }, { x2x, y2y } }; selectiveFilter.Optimum_notcha, K, D0,
ImgFFT.Obj.Width, ImgFFT.Obj.Height, 1, intn; ImgFFT.RemoveFFTShift;
for int p = 0; p 1; p++ {
for int v = 0; v ImgFFT.Obj.Height; v++ {
for int u = 0; u ImgFFT.Obj.Width; u++
{ MessageBox.Showa[u,
v].ToString; ImgFFT.FFTNormal[u, v].real = a[u,
v]; ImgFFT.Output[u, v].real =
ImgFFT.FFTNormal[u, v].real; ImgFFT.FFTNormal[u, v].imag = a[u,
v]; ImgFFT.Output[u, v].imag =
ImgFFT.FFTNormal[u, v].imag; }
} }
ImgFFT.RemoveFFTShift; ImgFFT.InverseFFT;
dua = DateTime.Now; ONF_I.Image = ImageImgFFT.Obj;
satu = DateTime.Now; ImgFFT = new FFTIs3;
ImgFFT.ForwardFFT; ImgFFT.FFTShift;
ImgFFT.FFTPlotImgFFT.FFTShifted; citraSpektrum.Image = ImageImgFFT.FourierPlot;
double[,] a1 = new double[ImgFFT.Obj.Width, ImgFFT.Obj.Height];
Universitas Sumatera Utara
int[,] K1 = { { x1x, y1y }, { x2x, y2y } }; selectiveFilter.Optimum_notcha1, K1, D0,
ImgFFT.Obj.Width, ImgFFT.Obj.Height, 2, intn; ImgFFT.RemoveFFTShift;
for int p = 0; p 1; p++ {
for int v = 0; v ImgFFT.Obj.Height; v++ {
for int u = 0; u ImgFFT.Obj.Width; u++
{ MessageBox.Showa[u,
v].ToString; ImgFFT.FFTNormal[u, v].real = a1[u,
v]; ImgFFT.Output[u, v].real =
ImgFFT.FFTNormal[u, v].real; ImgFFT.FFTNormal[u, v].imag = a1[u,
v]; ImgFFT.Output[u, v].imag =
ImgFFT.FFTNormal[u, v].imag; }
} }
ImgFFT.RemoveFFTShift; ImgFFT.InverseFFT;
dua = DateTime.Now; ONF_B.Image = ImageImgFFT.Obj;
satu = DateTime.Now; ImgFFT = new FFTIs3;
ImgFFT.ForwardFFT; ImgFFT.FFTShift;
ImgFFT.FFTPlotImgFFT.FFTShifted; citraSpektrum.Image = ImageImgFFT.FourierPlot;
double[,] a2 = new double[ImgFFT.Obj.Width, ImgFFT.Obj.Height];
int[,] K2 = { { x1x, y1y }, { x2x, y2y } }; selectiveFilter.Optimum_notcha2, K2, D0,
ImgFFT.Obj.Width, ImgFFT.Obj.Height, 3, intn; ImgFFT.RemoveFFTShift;
for int p = 0; p 1; p++ {
for int v = 0; v ImgFFT.Obj.Height; v++ {
for int u = 0; u ImgFFT.Obj.Width; u++
{ MessageBox.Showa[u,
v].ToString; ImgFFT.FFTNormal[u, v].real = a2[u,
v]; ImgFFT.Output[u, v].real =
ImgFFT.FFTNormal[u, v].real;
Universitas Sumatera Utara
ImgFFT.FFTNormal[u, v].imag = a2[u, v];
ImgFFT.Output[u, v].imag = ImgFFT.FFTNormal[u, v].imag;
} }
} ImgFFT.RemoveFFTShift;
ImgFFT.InverseFFT; dua = DateTime.Now;
ONF_G.Image = ImageImgFFT.Obj; MessageBox.ShowProses Filter selesai, tekan
tombol simpan untuk menyimpan gambar, Sukses, MessageBoxButtons.OK, MessageBoxIcon.Information;
} catch Exception ex
{ }
} }
public void SimpanMetodPictureBox abc {
if abc.Image = null {
Bitmap copy = new BitmapBitmapabc.Image; SaveFileDialog saveFileDialog = new SaveFileDialog;
saveFileDialog.InitialDirectory = ; saveFileDialog.Filter = Bitmap
Files.bmp|.bmp|Jpeg Files.jpg|.jpg|All valid files.bmp.jpg|.bmp.jpg;
saveFileDialog.FilterIndex = 2; saveFileDialog.RestoreDirectory = true;
if DialogResult.OK == saveFileDialog.ShowDialog {
copy.SavesaveFileDialog.FileName; }
} }
private void button3_Clickobject sender, EventArgs e {
SimpanMetodBR_ideal; }
private void button4_Clickobject sender, EventArgs e {
SimpanMetodBR_B; }
private void button5_Clickobject sender, EventArgs e {
SimpanMetodBR_G;
Universitas Sumatera Utara
} private void button6_Clickobject sender, EventArgs e
{ SimpanMetodONF_I;
} private void button7_Clickobject sender, EventArgs e
{ SimpanMetodONF_B;
} private void button8_Clickobject sender, EventArgs e
{ SimpanMetodONF_G;
} }
}
3. Kelas Selective_Filter