Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

private void button11_Click(object sender, EventArgs e)

{
float[] h = new float[256];
float[] c = new float[256];
int i;
for (i = 0; i < 256; i++)
h[i] = 0;
for (int x = 0; x < objBitmap1.Width; x++)
for (int y = 0; y < objBitmap1.Height; y++)
{
Color w = objBitmap1.GetPixel(x, y);
int xg = w.B;
Color wg = Color.FromArgb(xg, xg, xg);
objBitmap1.SetPixel(x, y, wg);

}
int nx1 = 1, nx2 = 203;
int ny1 = 190, ny2 = 526;
for (int x = nx1; x < nx2; x++)
for (int y = ny1; y < ny2; y++)
{
Color w = objBitmap1.GetPixel(x, y);
int xg = w.B;
h[xg] = h[xg] + 1;

}
c[0] = h[0];
for (i = 1; i < 256; i++) c[i] = c[i - 1] + h[i];
objBitmap2 = new Bitmap(objBitmap1);

for (int x = nx1; x < nx2; x++)


for (int y = ny1; y < ny2; y++)
{
Color w = objBitmap1.GetPixel(x, y);
int xg = w.B;
int xb = (int)(255 * c[xg] / (nx2 - nx1) / (ny2 - ny1));
Color wb = Color.FromArgb(xb, xb, xb);
objBitmap1.SetPixel(x, y, wb);
}
pictureBox2.Image = objBitmap1;
}

You might also like