public TypicalImage Add(TypicalImage second, float fraction) { TypicalImage img = new TypicalImage(this); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color color1 = img.buffer2d[x, y]; Color color2 = second.buffer2d[x, y]; float R, G, B; R = color1.R * fraction + color2.R * (1 - fraction); G = color1.G * fraction + color2.G * (1 - fraction); B = color1.B * fraction + color2.B * (1 - fraction); Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return(img); }
private void GammaForm_Load(object sender, EventArgs e) { try { int width, height; small_current = new TypicalImage(current_image); if (small_current.get_width() > 200 || small_current.get_height() > 200) { if (small_current.get_width() > small_current.get_height()) { width = 200; height = (width * small_current.get_height()) / small_current.get_width(); } else { height = 200; width = (height * small_current.get_width()) / small_current.get_height(); } small_current.resize(width, height); } this.Original.Image = this.small_current.get_bitmap(); this.Adjusted.Image = this.small_current.get_bitmap(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public TypicalImage edge_magnitude() { TypicalImage hor = this.horizontal_sobel_filter(); TypicalImage ver = this.vertical_sobel_filter(); TypicalImage mag = new TypicalImage(this); double [] buffer = new double[width * height * 3]; int z = 0; for (int j = 0; j < this.height; j++) { for (int i = 0; i < this.width; i++, z += 3) { int R = hor.buffer2d[i, j].R + ver.buffer2d[i, j].R; int G = hor.buffer2d[i, j].G + ver.buffer2d[i, j].G; int B = hor.buffer2d[i, j].B + ver.buffer2d[i, j].B; buffer[z] = R; buffer[z + 1] = G; buffer[z + 2] = B; } } normalization(buffer, mag); return(mag); }
public void resize(float Width, float Height, Interpolation interpol = Interpolation.Bilinear) { TypicalImage newImg = new TypicalImage(this); Matrix transform_matrix = new Matrix(); float ScaleX = Width / (float)width, ScaleY = Height / (float)height; transform_matrix.Scale(ScaleX, ScaleY); newImg.Transform(transform_matrix, interpol); if (newImg.width == Width && newImg.height == height) { this.Transform(transform_matrix, interpol); } else { this.bitmap = new Bitmap(this.bitmap, new Size((int)Width, (int)Height)); this.width = this.bitmap.Width; this.height = this.bitmap.Height; buffer2d = new Color[width, height]; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { buffer2d[i, j] = bitmap.GetPixel(i, j); } } } }
public void bitplane() { BitPlaneForm bitPlaneForm = new BitPlaneForm(); bitPlaneForm.source = this.opened_image; bitPlaneForm.ShowDialog(this); this.opened_image = bitPlaneForm.source; set_new_image(); }
public void brightness_contrast() { BrightnessContrastForm brightness_contrast_form = new BrightnessContrastForm(); brightness_contrast_form.current_image = this.opened_image; brightness_contrast_form.ShowDialog(this); this.opened_image = brightness_contrast_form.current_image; set_new_image(); }
public void custom_filter() { CustomFilterForm customFilter = new CustomFilterForm(); customFilter.img = this.opened_image; customFilter.ShowDialog(this); this.opened_image = customFilter.img; set_new_image(); }
public void gamma_correction() { GammaForm gamma_correction_form = new GammaForm(); gamma_correction_form.current_image = this.opened_image; gamma_correction_form.ShowDialog(this); this.opened_image = gamma_correction_form.current_image; set_new_image(); }
public TypicalImage change_brightness(int add_value) { TypicalImage img = new TypicalImage(this); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color colr = this.buffer2d[x, y]; int R, G, B; if (colr.R + add_value > 255) { R = 255; } else if (colr.R + add_value < 0) { R = 0; } else { R = colr.R + add_value; } if (colr.G + add_value > 255) { G = 255; } else if (colr.G + add_value < 0) { G = 0; } else { G = colr.G + add_value; } if (colr.B + add_value > 255) { B = 255; } else if (colr.B + add_value < 0) { B = 0; } else { B = colr.B + add_value; } Color new_colr = Color.FromArgb(R, G, B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return(img); }
private void dropListImage1_SelectedIndexChanged(object sender, EventArgs e) { try { first = new TypicalImage(images_array[dropListImage1.SelectedIndex]); FirstImage.Image = first.get_bitmap(); } catch(Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonOK_Click(object sender, EventArgs e) { try { img = bluredimg; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public TypicalImage change_contrast(int _value) { TypicalImage img = new TypicalImage(this); calculate_intensity_min_max(); float oldmin = (float)min_intensity, oldmax = (float)max_intensity, newmin = oldmin - (float)_value, newmax = oldmax + (float)_value; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color colr = this.buffer2d[x, y]; float R = (colr.R - oldmin) / (oldmax - oldmin) * (newmax - newmin) + newmin, G = (colr.G - oldmin) / (oldmax - oldmin) * (newmax - newmin) + newmin, B = (colr.B - oldmin) / (oldmax - oldmin) * (newmax - newmin) + newmin; if (R > 255) { R = 255; } else if (R < 0) { R = 0; } if (G > 255) { G = 255; } else if (G < 0) { G = 0; } if (B > 255) { B = 255; } else if (B < 0) { B = 0; } Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return(img); }
public TypicalImage LinearFilter(float[,] filter, int Origx, int Origy, Postprocessing post) { TypicalImage img = new TypicalImage(this); TypicalImage edited_img = new TypicalImage(this); int padWidth, padHeight; double[] buffer = new double[width * height * 3]; int z = 0; padWidth = Math.Max(FWidth - Origx, Origx); padHeight = Math.Max(FHeight - Origy, Origy); img.padding(padWidth, padHeight); for (int y = padHeight; y < height + padHeight; y++) { for (int x = padWidth; x < width + padWidth; x++, z += 3) { float R = 0, G = 0, B = 0; for (int i = 0; i < FWidth; i++) { for (int j = 0; j < FHeight; j++) { R += img.buffer2d[x - Origx + i, y - Origy + j].R * filter[i, j]; G += img.buffer2d[x - Origx + i, y - Origy + j].G * filter[i, j]; B += img.buffer2d[x - Origx + i, y - Origy + j].B * filter[i, j]; } } buffer[z] = R; buffer[z + 1] = G; buffer[z + 2] = B; } } if (post == Postprocessing.Cut_off) { edited_img.cut_off(buffer); } else if (post == Postprocessing.No) { edited_img.no_postprocess(buffer); } else if (post == Postprocessing.Absolute) { edited_img.absolute(buffer); } else if (post == Postprocessing.Normalization) { edited_img.normalization(buffer, edited_img); } return(edited_img); }
private void buttonOK_Click(object sender, EventArgs e) { try { current_image = current_image.change_gamma(Convert.ToDouble(this.numericGamma.Value)); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public TypicalImage(TypicalImage img) { this.width = img.width; this.height = img.height; this.bitmap = new Bitmap(img.bitmap); this.buffer2d = new Color[width, height]; for (int y = 0; y < this.height; y++) { for (int x = 0; x < this.width; x++) { this.buffer2d[x, y] = img.buffer2d[x, y]; } } this.original_format = img.original_format; this.max_color = img.max_color; this.file_name = img.file_name; this.id = img.id; }
private void guassianButton_Click(object sender, EventArgs e) { try { if (gaussianSize.Text == "") { bluredimg = img.gaussianFilter2(int.Parse(sigma.Text)); pictureBoxResult.Image = bluredimg.get_bitmap(); } else { bluredimg =img.gaussianFilter1(int.Parse(sigma.Text), int.Parse(gaussianSize.Text)); pictureBoxResult.Image = bluredimg.get_bitmap(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public TypicalImage bitplane_slicing(Color _color) { TypicalImage img = new TypicalImage(this); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int R, G, B; R = this.buffer2d[x, y].R & _color.R; G = this.buffer2d[x, y].G & _color.G; B = this.buffer2d[x, y].B & _color.B; Color new_color = Color.FromArgb(R, G, B); img.buffer2d[x, y] = new_color; img.bitmap.SetPixel(x, y, new_color); } } return(img); }
public void normalization(double[] buffer, TypicalImage image) { double min = buffer[0], max = 0; for (int i = 0; i < buffer.Length; i++) { if (buffer[i] > max) { max = buffer[i]; } if (buffer[i] < min) { min = buffer[i]; } } double newmin = 0, newmax = 255; int z = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, z += 3) { double R = (buffer[z] - min) / (max - min) * (newmax - newmin) + newmin, G = (buffer[z + 1] - min) / (max - min) * (newmax - newmin) + newmin, B = (buffer[z + 2] - min) / (max - min) * (newmax - newmin) + newmin; Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); image.bitmap.SetPixel(x, y, new_colr); image.buffer2d[x, y] = new_colr; } } }
public TypicalImage change_gamma(double gamma_value) { TypicalImage img = new TypicalImage(this); double[] buffer = new double[width * height * 3]; double min = buffer2d[0, 0].R, max = 0; int z = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, z += 3) { Color colr = this.buffer2d[x, y]; double R, G, B; if(gamma_value <= 0) { R = colr.R; G = colr.G; B = colr.B; } else { R = Math.Pow(colr.R, gamma_value); G = Math.Pow(colr.G, gamma_value); B = Math.Pow(colr.B, gamma_value); } buffer[z] = R; buffer[z + 1] = G; buffer[z + 2] = B; if (R > max) max = R; if (R < min) min = R; if (G > max) max = G; if (G < min) min = G; if (B > max) max = B; if (B < min) min = B; } } normalization(buffer, img); //double newmin = 0, //newmax = 255; //z = 0; //for (int y = 0; y < height; y++) //{ // for (int x = 0; x < width; x++, z += 3) // { // double R = (buffer[z] - min) / (max - min) * (newmax - newmin) + newmin, // G = (buffer[z + 1] - min) / (max - min) * (newmax - newmin) + newmin, // B = (buffer[z + 2] - min) / (max - min) * (newmax - newmin) + newmin; // Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); // img.bitmap.SetPixel(x, y, new_colr); // img.buffer2d[x, y] = new_colr; // } //} return img; }
public TypicalImage change_contrast(int _value) { TypicalImage img = new TypicalImage(this); calculate_intensity_min_max(); float oldmin = (float)min_intensity, oldmax = (float)max_intensity, newmin = oldmin - (float)_value, newmax = oldmax + (float)_value; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color colr = this.buffer2d[x, y]; float R = (colr.R - oldmin) / (oldmax - oldmin) * (newmax - newmin) + newmin, G = (colr.G - oldmin) / (oldmax - oldmin) * (newmax - newmin) + newmin, B = (colr.B - oldmin) / (oldmax - oldmin) * (newmax - newmin) + newmin; if (R > 255) R = 255; else if (R < 0) R = 0; if (G > 255) G = 255; else if (G < 0) G = 0; if (B > 255) B = 255; else if (B < 0) B = 0; Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return img; }
public TypicalImage change_brightness(int add_value) { TypicalImage img = new TypicalImage(this); for(int y = 0; y < height; y++) { for(int x = 0; x < width; x++) { Color colr = this.buffer2d[x, y]; int R, G, B; if (colr.R + add_value > 255) R = 255; else if (colr.R + add_value < 0) R = 0; else R = colr.R + add_value; if (colr.G + add_value > 255) G = 255; else if (colr.G + add_value < 0) G = 0; else G = colr.G + add_value; if (colr.B + add_value > 255) B = 255; else if (colr.B + add_value < 0) B = 0; else B = colr.B + add_value; Color new_colr = Color.FromArgb(R, G, B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return img; }
public TypicalImage bitplane_slicing(Color _color) { TypicalImage img = new TypicalImage(this); for (int y = 0; y < height; y++) { for(int x = 0; x < width; x++) { int R, G, B; R = this.buffer2d[x, y].R & _color.R; G = this.buffer2d[x, y].G & _color.G; B = this.buffer2d[x, y].B & _color.B; Color new_color = Color.FromArgb(R, G, B); img.buffer2d[x, y] = new_color; img.bitmap.SetPixel(x, y, new_color); } } return img; }
public TypicalImage bitplane(char color, int mask) { TypicalImage img = new TypicalImage(this); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color color1 = this.buffer2d[x, y]; float R = 255, G = 255, B = 255; if (color == 'R') { R = color1.R & mask; if (R == mask) { R = 255; G = 0; B = 0; } else { R = 245; G = 245; B = 245; } } else if (color == 'G') { G = color1.G & mask; if (G == mask) { R = 0; G = 255; B = 0; } else { R = 245; G = 245; B = 245; } } else if (color == 'B') { B = color1.B & mask; if (B == mask) { R = 0; G = 0; B = 255; } else { R = 245; G = 245; B = 245; } } Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return img; }
public TypicalImage Add(TypicalImage second, float fraction) { TypicalImage img = new TypicalImage(this); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color color1 = img.buffer2d[x, y]; Color color2 = second.buffer2d[x, y]; float R, G, B; R = color1.R * fraction + color2.R * (1 - fraction); G = color1.G * fraction + color2.G * (1 - fraction); B = color1.B * fraction + color2.B * (1 - fraction); Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return img; }
public void sharp() { this.opened_image = this.opened_image.laplacianFilter(); this.set_new_image(); }
public void resize(float Width, float Height, Interpolation interpol = Interpolation.Bilinear) { TypicalImage newImg = new TypicalImage(this); Matrix transform_matrix = new Matrix(); float ScaleX = Width / (float)width, ScaleY = Height / (float)height; transform_matrix.Scale(ScaleX, ScaleY); newImg.Transform(transform_matrix, interpol); if(newImg.width == Width && newImg.height == height) { this.Transform(transform_matrix, interpol); } else { this.bitmap = new Bitmap(this.bitmap, new Size((int)Width, (int)Height)); this.width = this.bitmap.Width; this.height = this.bitmap.Height; buffer2d = new Color[width, height]; for(int j = 0; j < height; j++) { for(int i = 0; i < width; i++) { buffer2d[i, j] = bitmap.GetPixel(i, j); } } } }
public TypicalImage LinearFilter(float[,] filter,int Origx, int Origy, Postprocessing post) { TypicalImage img = new TypicalImage(this); TypicalImage edited_img = new TypicalImage(this); int padWidth, padHeight; double[] buffer = new double[width * height * 3]; int z = 0 ; padWidth = Math.Max(FWidth - Origx, Origx); padHeight = Math.Max(FHeight - Origy, Origy); img.padding(padWidth, padHeight); for (int y = padHeight; y < height + padHeight; y++) { for (int x = padWidth; x < width + padWidth; x++,z += 3) { float R = 0, G = 0, B = 0; for (int i = 0; i < FWidth; i++) { for (int j = 0; j < FHeight; j++) { R += img.buffer2d[x - Origx + i, y - Origy + j].R * filter[i, j]; G += img.buffer2d[x - Origx + i, y - Origy + j].G * filter[i, j]; B += img.buffer2d[x - Origx + i, y - Origy + j].B * filter[i, j]; } } buffer[z] = R; buffer[z + 1] = G; buffer[z + 2] = B; } } if (post == Postprocessing.Cut_off) { edited_img.cut_off(buffer); } else if (post == Postprocessing.No) { edited_img.no_postprocess(buffer); } else if (post == Postprocessing.Absolute) { edited_img.absolute(buffer); } else if (post == Postprocessing.Normalization) { edited_img.normalization(buffer, edited_img); } return edited_img; }
private void dropListImage2_SelectedIndexChanged(object sender, EventArgs e) { try { second = new TypicalImage(images_array[dropListImage2.SelectedIndex]); SecondImage.Image = second.get_bitmap(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public TypicalImage change_gamma(double gamma_value) { TypicalImage img = new TypicalImage(this); double[] buffer = new double[width * height * 3]; double min = buffer2d[0, 0].R, max = 0; int z = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, z += 3) { Color colr = this.buffer2d[x, y]; double R, G, B; if (gamma_value <= 0) { R = colr.R; G = colr.G; B = colr.B; } else { R = Math.Pow(colr.R, gamma_value); G = Math.Pow(colr.G, gamma_value); B = Math.Pow(colr.B, gamma_value); } buffer[z] = R; buffer[z + 1] = G; buffer[z + 2] = B; if (R > max) { max = R; } if (R < min) { min = R; } if (G > max) { max = G; } if (G < min) { min = G; } if (B > max) { max = B; } if (B < min) { min = B; } } } normalization(buffer, img); //double newmin = 0, //newmax = 255; //z = 0; //for (int y = 0; y < height; y++) //{ // for (int x = 0; x < width; x++, z += 3) // { // double R = (buffer[z] - min) / (max - min) * (newmax - newmin) + newmin, // G = (buffer[z + 1] - min) / (max - min) * (newmax - newmin) + newmin, // B = (buffer[z + 2] - min) / (max - min) * (newmax - newmin) + newmin; // Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); // img.bitmap.SetPixel(x, y, new_colr); // img.buffer2d[x, y] = new_colr; // } //} return(img); }
public void vertical_edge() { this.opened_image = this.opened_image.vertical_sobel_filter(); this.set_new_image(); }
public void horizontal_edge() { this.opened_image = this.opened_image.horizontal_sobel_filter(); this.set_new_image(); }
public TypicalImage Subtract(TypicalImage second) { TypicalImage img = new TypicalImage(this); double[] buffer = new double[width * height * 3]; double min = buffer2d[0, 0].R; double max = buffer2d[0, 0].R; int z = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, z += 3) { Color color1 = img.buffer2d[x, y]; Color color2 = second.buffer2d[x, y]; double R, G, B; R = color1.R - color2.R; G = color1.G - color2.G; B = color1.B - color2.B; buffer[z] = R; buffer[z + 1] = G; buffer[z + 2] = B; if (R > max) { max = R; } if (R < min) { min = R; } if (G > max) { max = G; } if (G < min) { min = G; } if (B > max) { max = B; } if (B < min) { min = B; } } } double newmin = 0, newmax = 255; z = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, z += 3) { double R = (buffer[z] - min) / (max - min) * (newmax - newmin) + newmin, G = (buffer[z + 1] - min) / (max - min) * (newmax - newmin) + newmin, B = (buffer[z + 2] - min) / (max - min) * (newmax - newmin) + newmin; Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return(img); }
public TypicalImage edge_magnitude() { TypicalImage hor = this.horizontal_sobel_filter(); TypicalImage ver = this.vertical_sobel_filter(); TypicalImage mag = new TypicalImage(this); double [] buffer = new double[width*height *3]; int z=0; for (int j = 0; j < this.height; j++) { for (int i = 0; i < this.width; i++, z += 3) { int R = hor.buffer2d[i, j].R + ver.buffer2d[i, j].R; int G = hor.buffer2d[i, j].G + ver.buffer2d[i, j].G; int B = hor.buffer2d[i, j].B + ver.buffer2d[i, j].B; buffer[z] = R; buffer[z + 1] = G; buffer[z + 2] = B; } } normalization(buffer,mag); return mag; }
public TypicalImage bitplane(char color, int mask) { TypicalImage img = new TypicalImage(this); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color color1 = this.buffer2d[x, y]; float R = 255, G = 255, B = 255; if (color == 'R') { R = color1.R & mask; if (R == mask) { R = 255; G = 0; B = 0; } else { R = 245; G = 245; B = 245; } } else if (color == 'G') { G = color1.G & mask; if (G == mask) { R = 0; G = 255; B = 0; } else { R = 245; G = 245; B = 245; } } else if (color == 'B') { B = color1.B & mask; if (B == mask) { R = 0; G = 0; B = 255; } else { R = 245; G = 245; B = 245; } } Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return(img); }
public void magnitude_edge() { this.opened_image = this.opened_image.edge_magnitude(); this.set_new_image(); }
public void normalization(double[] buffer, TypicalImage image) { double min = buffer[0], max = 0; for (int i = 0; i < buffer.Length; i++) { if (buffer[i] > max) max = buffer[i]; if (buffer[i] < min) min = buffer[i]; } double newmin = 0, newmax = 255; int z = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, z += 3) { double R = (buffer[z] - min) / (max - min) * (newmax - newmin) + newmin, G = (buffer[z + 1] - min) / (max - min) * (newmax - newmin) + newmin, B = (buffer[z + 2] - min) / (max - min) * (newmax - newmin) + newmin; Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); image.bitmap.SetPixel(x, y, new_colr); image.buffer2d[x, y] = new_colr; } } }
private void meanSmooth_Click(object sender, EventArgs e) { try { bluredimg = img.meanFilter( int.Parse(meanWidth.Text), int.Parse(meanHeight.Text), int.Parse(meanOrigix.Text), int.Parse(meanOriginy.Text) ); pictureBoxResult.Image = bluredimg.get_bitmap(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void smooth() { SmoothForm smoothForm = new SmoothForm(); smoothForm.img = this.opened_image; smoothForm.ShowDialog(this); this.opened_image = smoothForm.img; this.set_new_image(); }
public TypicalImage Subtract(TypicalImage second) { TypicalImage img = new TypicalImage(this); double[] buffer = new double[width * height * 3]; double min = buffer2d[0, 0].R; double max = buffer2d[0, 0].R; int z = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, z += 3) { Color color1 = img.buffer2d[x, y]; Color color2 = second.buffer2d[x, y]; double R, G, B; R = color1.R - color2.R; G = color1.G - color2.G; B = color1.B - color2.B; buffer[z] = R; buffer[z + 1] = G; buffer[z + 2] = B; if (R > max) max = R; if (R < min) min = R; if (G > max) max = G; if (G < min) min = G; if (B > max) max = B; if (B < min) min = B; } } double newmin = 0, newmax = 255; z = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, z += 3) { double R = (buffer[z] - min) / (max - min) * (newmax - newmin) + newmin, G = (buffer[z + 1] - min) / (max - min) * (newmax - newmin) + newmin, B = (buffer[z + 2] - min) / (max - min) * (newmax - newmin) + newmin; Color new_colr = Color.FromArgb((int)R, (int)G, (int)B); img.bitmap.SetPixel(x, y, new_colr); img.buffer2d[x, y] = new_colr; } } return img; }
private void SharpForm_Load(object sender, EventArgs e) { try { Original.Image = img.get_bitmap(); comboBoxpost.SelectedIndex = 0; edited = new TypicalImage(img); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void transformation() { TransformationsForm trans_form = new TransformationsForm(); trans_form.working_on = this.opened_image; trans_form.ShowDialog(this); this.opened_image = trans_form.working_on; set_new_image(); }