←Select platform

DesaturateCommand Class

Summary
Converts the image to a grayscale level by reducing the saturation of each color to zero. The conversion will not change the color resolution.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public class DesaturateCommand : RasterCommand 
@interface LTDesaturateCommand : LTRasterCommand 
public class DesaturateCommand 
    extends RasterCommand 
public ref class DesaturateCommand : public RasterCommand   
class DesaturateCommand(RasterCommand): 
Remarks
  • The image is converted to a grayscale level by reducing the saturation of each color to zero.
  • This class supports only RGB images. It does not support grayscale images.
  • Support for 48-bit and 64-bit colored images are available only in the Document/Medical toolkits.
  • This class does not support signed data images.
  • This command does not support 32-bit grayscale images.

For more information, refer to Introduction to Image Processing With LEADTOOLS. For more information, refer to Grayscale Images.

Desaturate Function - Before

Desaturate Function - Before

Desaturate Function - After

Desaturate Function - After

View additional platform support for this Desaturate function.

Example

Run the DesaturateCommand on an image.

C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Color; 
 
 
public void DesaturateCommandExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "sample5.cmp")); 
 
   // Prepare the command 
   // Apply deSaturate effect on the image. 
   DesaturateCommand command = new DesaturateCommand(); 
   command.Run(image); 
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24); 
 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Color Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.