DicomImageDither Method (DitheringMethod, Int32, IColorPalette)
Performs dithering on the current image.

Namespace: Aspose.Imaging.FileFormats.Dicom
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.04
Syntax
public override void Dither(
	DitheringMethod ditheringMethod,
	int bitsCount,
	IColorPalette customPalette
)

Parameters

ditheringMethod
Type: Aspose.ImagingDitheringMethod
The dithering method.
bitsCount
Type: SystemInt32
The final bits count for dithering.
customPalette
Type: Aspose.ImagingIColorPalette
The custom palette for dithering.
Examples
The following example loads a DICOM image and performs threshold and floyd dithering using different palette depth.
[C#]

string dir = "c:\\temp\\";

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
    Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;

    // Perform threshold dithering using 4-bit color palette which contains 16 colors.
    // The more bits specified the higher quality and the bigger size of the output image.
    // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
    dicomImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4, null);

    dicomImage.Save(dir + "sample.ThresholdDithering4.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.dicom"))
{
    Aspose.Imaging.FileFormats.Dicom.DicomImage dicomImage = (Aspose.Imaging.FileFormats.Dicom.DicomImage)image;

    // Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
    // The more bits specified the higher quality and the bigger size of the output image.
    // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
    dicomImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1, null);

    dicomImage.Save(dir + "sample.FloydSteinbergDithering1.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
See Also