GrayscaleFilter Class

Converts the image to grayscale using a mixture of the color components.

Namespace: Lumia.Imaging.Adjustments
Assembly: Lumia.Imaging (in Lumia.Imaging.dll) Version:

Lumia.Imaging.Adjustments.GrayscaleFilter = function();


The gray shade is calculated by multiplying each color component of every pixel with the matching weight and adding a constant: resultShade = redValue * redWeight + greenValue * greenWeight + blueValue * blueWeight + constant. The resulting shade is clamped to the range [0,1].

using (var filterEffect = new FilterEffect(source))
    // Initialize the filter and add the filter to the FilterEffect collection
    var filter = new GrayscaleFilter();

    filterEffect.Filters = new IFilter[] { filter };

    // Create a target where the filtered image will be rendered to
    var target = new WriteableBitmap(width, height);

    // Create a new renderer which outputs WriteableBitmaps
    using (var renderer = new WriteableBitmapRenderer(filterEffect, target))
        // Render the image with the filter(s)
        await renderer.RenderAsync();

        // Set the output image to Image control as a source
        ImageControl.Source = target;

    await SaveEffectAsync(filterEffect, "GrayscaleFilter.jpg", outputImageSize);


Lumia Imaging SDK

Supported in: 2.0