public void Initialiser(OpenFileDialog openFileDialog) { HSLconvertor = new HSLconvertor(); this.img = new Bitmap(openFileDialog.FileName); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.Image = img; this.width = img.Width; this.height = img.Height; RGBcolor = new RGBcolor(); RGBcolor.A = new int[width, height]; RGBcolor.R = new int[width, height]; RGBcolor.G = new int[width, height]; RGBcolor.B = new int[width, height]; }
private void button4_Click(object sender, EventArgs e) // лінеаризація { double min = double.Parse(textBox1.Text); double max = double.Parse(textBox2.Text); float L_new = float.Parse(textBox3.Text); imgLinerized = new Bitmap(img); HSLconvertor hsl = new HSLconvertor(); hsl.toHSL(RGBcolor, img.Height, img.Width); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { if (hsl.L[i, j] > min && hsl.L[i, j] < max) { hsl.L[i, j] = L_new; } } } RGBcolor rgb = new RGBcolor(); rgb = hsl.toRGB(RGBcolor.A); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { imgLinerized.SetPixel(x, y, Color.FromArgb(rgb.A[x, y], rgb.R[x, y], rgb.G[x, y], rgb.B[x, y])); } } pictureBox4.SizeMode = PictureBoxSizeMode.Zoom; pictureBox4.Image = imgLinerized; }