Vous êtes sur la page 1sur 5

LAPORAN RESMI

PENGOLAHAN CITRA
(Color Detection)

Arrachmad Nur Fauzie


2103187087

PJJ D3 AK TEKNIK INFORMATIKA


POLITEKNIK ELEKTRONIKA NEGERI SURABAYA
2018
Laporan resmi color detection pada sampel wajah dan bunga tentukan range rgb pada
static detection dan rata2 rgb pada distance detection.

Membuat Form Color Detection

Color Detection pada wajah


namespace ColorDetiction
{
public partial class Form1 : Form
{
Bitmap objBitmap;
Bitmap objBitmap1;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
DialogResult d = openFileDialog1.ShowDialog();
if (d == DialogResult.OK)
{
objBitmap = new Bitmap(openFileDialog1.FileName);
pictureBox1.Image = objBitmap;
}
}

private void button2_Click(object sender, EventArgs e)


{
objBitmap1 = new Bitmap(objBitmap);
Color w1;
for (int x = 1; x < objBitmap1.Width - 1; x++)
for (int y = 1; y < objBitmap1.Height - 1; y++)
{
Color w = objBitmap1.GetPixel(x, y);
if (((w.R > 102) && (w.R < 160)) && ((w.G > 70) && (w.G < 100)) &&
((w.B > 0) && (w.B > 50)))
w1 = Color.FromArgb(w.R, w.G, w.B);
else
w1 = Color.FromArgb(0, 0, 0);
objBitmap1.SetPixel(x, y, w1);
}
pictureBox2.Image = objBitmap1;

private void button3_Click(object sender, EventArgs e)


{
objBitmap1 = new Bitmap(objBitmap);
Color w1; int d;
int r = 144, g = 89, b = 65;
for (int x = 1; x < objBitmap1.Width - 1; x++)
for (int y = 1; y < objBitmap1.Height - 1; y++)
{
Color w = objBitmap1.GetPixel(x, y);
d = Math.Abs(w.R - r) + Math.Abs(w.G - g) + Math.Abs(w.B - b);
if (d < 300)
w1 = Color.FromArgb(w.R, w.G, w.B);
else
w1 = Color.FromArgb(0, 0, 0);
objBitmap1.SetPixel(x, y, w1);
}
pictureBox3.Image = objBitmap1;
}
}
}

Hasil
Color Detection pada bunga
namespace ColorDetiction
{
public partial class Form1 : Form
{
Bitmap objBitmap;
Bitmap objBitmap1;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
DialogResult d = openFileDialog1.ShowDialog();
if (d == DialogResult.OK)
{
objBitmap = new Bitmap(openFileDialog1.FileName);
pictureBox1.Image = objBitmap;
}
}

private void button2_Click(object sender, EventArgs e)


{
objBitmap1 = new Bitmap(objBitmap);
Color w1;
for (int x = 1; x < objBitmap1.Width - 1; x++)
for (int y = 1; y < objBitmap1.Height - 1; y++)
{
Color w = objBitmap1.GetPixel(x, y);
if (((w.R > 200) && (w.R < 220)) && ((w.G > 15) && (w.G < 50)) &&
((w.B > 0) && (w.B > 20)))
w1 = Color.FromArgb(w.R, w.G, w.B);
else
w1 = Color.FromArgb(0, 0, 0);
objBitmap1.SetPixel(x, y, w1);
}
pictureBox2.Image = objBitmap1;

private void button3_Click(object sender, EventArgs e)


{
objBitmap1 = new Bitmap(objBitmap);
Color w1; int d;
int r = 212, g = 20, b = 16;
for (int x = 1; x < objBitmap1.Width - 1; x++)
for (int y = 1; y < objBitmap1.Height - 1; y++)
{
Color w = objBitmap1.GetPixel(x, y);
d = Math.Abs(w.R - r) + Math.Abs(w.G - g) + Math.Abs(w.B - b);
if (d < 300)
w1 = Color.FromArgb(w.R, w.G, w.B);
else
w1 = Color.FromArgb(0, 0, 0);
objBitmap1.SetPixel(x, y, w1);
}
pictureBox3.Image = objBitmap1;
}
}
}

Hasil

Vous aimerez peut-être aussi