public static Bitmap AutoColorCorrections(Bitmap source) { if (source == null) throw new ArgumentNullException("source"); //Bitmap output = null; ContrastStretch filter = new ContrastStretch(); filter.ApplyInPlace(source); //float brightness = 1.0f; // no change in brightness //float contrast = 2.0f; // twice the contrast //float gamma = 1.0f; // no change in gamma //float adjustedBrightness = brightness - 1.0f; //// create matrix that will brighten and contrast the image //float[][] ptsArray ={ // new float[] {contrast, 0, 0, 0, 0}, // scale red // new float[] {0, contrast, 0, 0, 0}, // scale green // new float[] {0, 0, contrast, 0, 0}, // scale blue // new float[] {0, 0, 0, 1.0f, 0}, // don't scale alpha // new float[] {adjustedBrightness, adjustedBrightness, adjustedBrightness, 0, 1}}; //using (ImageAttributes imageAttrs = new ImageAttributes()) //{ // imageAttrs.ClearColorMatrix(); // imageAttrs.SetColorMatrix(new ColorMatrix(ptsArray), ColorMatrixFlag.Default, ColorAdjustType.Bitmap); // imageAttrs.SetGamma(gamma, ColorAdjustType.Bitmap); // using (Graphics g = Graphics.FromImage(output)) // { // g.DrawImage(source, new Rectangle(0, 0, output.Width, output.Height), 0, 0, source.Width, source.Height, GraphicsUnit.Pixel, imageAttrs); // } //} return source; }
private void Contrast_scretchFunc(ref Bitmap frame, int par_int, double par_d, int par_R, int par_G, int par_B) { ContrastStretch filter = new ContrastStretch(); // process image filter.ApplyInPlace(frame); }
private void contrastStretch_Click(object sender, RoutedEventArgs e) { if (contrastStretch.IsChecked == true) { ContrastStretch filter = new ContrastStretch(); filter.ApplyInPlace(mainPhoto); Photography.Source = ToBitmapImage(mainPhoto); } else { UpdatePicture(ImageURL); Photography.Source = ToBitmapImage(mainPhoto); } mainPhotoIS = Photography.Source; UpdateHistograms(null); UpdateChannelPreviews(null); }
private void Contrast_scretchFunc(ref Bitmap frame) { ContrastStretch filter = new ContrastStretch(); // process image filter.ApplyInPlace(frame); }