AdjustGamma

DicomImage.AdjustGamma method (1 of 2)

Enhance image quality and adjust it with gamma correction, a powerful technique for fine-tuning visual appearance. Perfect for developers aiming to optimize image presentation, adjust color balance, and ensure consistent rendering across different devices and environments.

public override void AdjustGamma(float gamma)
ParameterTypeDescription
gammaSingleGamma for red, green and blue channels coefficient

Examples

The following example performs gamma-correction of a DICOM image.

[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;

    // Set gamma coefficient for red, green and blue channels.
    dicomImage.AdjustGamma(2.5f);
    dicomImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

See Also


DicomImage.AdjustGamma method (2 of 2)

Achieve precise color adjustments by applying gamma correction independently to the red, green, and blue components of an image. This method ensures accurate color balance and optimal visual output, catering to developers seeking granular control over image rendering and color accuracy.

public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
ParameterTypeDescription
gammaRedSingleGamma for red channel coefficient
gammaGreenSingleGamma for green channel coefficient
gammaBlueSingleGamma for blue channel coefficient

Examples

The following example performs gamma-correction of a DICOM image applying different coefficients for color components.

[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;

    // Set individual gamma coefficients for red, green and blue channels.
    dicomImage.AdjustGamma(1.5f, 2.5f, 3.5f);
    dicomImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

See Also