Article From:
WPF: grayscale processing of images.

Before the treatment:image      After treatment:image


This function is used.FormatConvertedBitmap(byBitmapSourceProviding pixel format conversion function


The code is as follows:


public partial class MainWindow : Window
    public MainWindow()
        Image img = new Image();
        BitmapImage bitmapImage = new BitmapImage(new Uri(“D:\\Face.jpg”));

        FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap();
        newFormatedBitmapSource.Source = bitmapImage;
        newFormatedBitmapSource.DestinationFormat = PixelFormats.Gray8;

        img.Source = newFormatedBitmapSource;
        this.Content = img;

Link of this Article: WPF processes grayscale images.

Leave a Reply

Your email address will not be published. Required fields are marked *