LEADTOOLS Image Processing (Leadtools.ImageProcessing.SpecialEffects assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
IntelligentDownScaleCommand Class
See Also  Members  
Leadtools.ImageProcessing.SpecialEffects Namespace : IntelligentDownScaleCommand Class



Automatically reduces image size while preserving important features. It can also remove or preserve certain objects chosen by the user without affecting the natural look of the image.

Object Model

IntelligentDownScaleCommand Class

Syntax

Visual Basic (Declaration) 
Public Class IntelligentDownScaleCommand 
   Inherits Leadtools.ImageProcessing.RasterCommand
   Implements IRasterCommand 
Visual Basic (Usage)Copy Code
Dim instance As IntelligentDownScaleCommand
C# 
public class IntelligentDownScaleCommand : Leadtools.ImageProcessing.RasterCommand, IRasterCommand  
C++/CLI 
public ref class IntelligentDownScaleCommand : public Leadtools.ImageProcessing.RasterCommand, IRasterCommand  

Example

Visual BasicCopy Code
Public Sub IntelligentDownScaleCommandExample()
   ' Load an image
   Dim Codecs As RasterCodecs = New RasterCodecs()
   Codecs.ThrowExceptionsOnInvalidImages = True

   Dim image As RasterImage = Codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Sample3.cmp"))

   Dim Command As IntelligentDownScaleCommand = New IntelligentDownScaleCommand()
   Command.DownScalingOrder = 1
   Command.NewWidth = image.Width - 100
   Command.NewHeight = image.Height
   Command.UsePreserveObjectColor = False
   Command.UseRemoveObjectColor = False

   ' Apply the intelligent downscale on the image.
   Command.Run(image)
   Codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IntelligentDownScaleResult.jpg"), RasterImageFormat.Jpeg, 24)

End Sub


Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void IntelligentDownScaleCommandExample()
   {
      // Load an image
      RasterCodecs codecs = new RasterCodecs();
      codecs.ThrowExceptionsOnInvalidImages = true;

      RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Sample3.cmp"));

      IntelligentDownScaleCommand command = new IntelligentDownScaleCommand();
      command.DownScalingOrder = 1;
      command.NewWidth = image.Width - 100;
      command.NewHeight = image.Height;
      command.UsePreserveObjectColor = false;
      command.UseRemoveObjectColor = false;

      // Apply the intelligent downscale on the image.
      command.Run(image);
      codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IntelligentDownScaleResult.jpg"), RasterImageFormat.Jpeg, 24);

   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}

Remarks

  • Dark areas are sometimes affected during downscaling since they are considered unimportant. If dark objects are affected during downscaling, the user can apply a Negative effect to the image, apply downscaling, and then apply the Negative effect to the image again to get the colors of original image. Alternatively the user can apply a mask on dark objects to keep them from being affected.
  • Downscaling is limited on images that are too condensed or where the content layout prevents downscaling without harming important aspects of the image.
  • Downscaling using a mask is performed only on width dimension. If the user wants to downscale using a mask on height dimension, rotate the image, downscale it on width dimension and rotate to the original orientation.
  • The color of the area to be removed must be different than colors in the image.
  • The color of the area to be preserved must be different than the colors in the image and different from the color of the area to be removed.
  • If multiple remove objects exist, then all of them have to be the same color of the area being removed. This also applies to a color area that is being preserved.
  • If the user wants the resulting size of a removal to be equal to the original size, then the user has to set new width equal to image width. This does NOT apply to preserve area and does NOT apply to the upscaling process.
  • Sometimes, letting the program determine the resulting width does not totally delete the area to be removed, the user needs to pass a new width to the original image that is less than the width of the resulting image with remaining portions of the removed area. For instance, if the downscaled image still has few pixels of the remove area after downscaling and its width is 300, the user can redo the downscaling on the original image but with a new width of 290.
  • If mask has an area to be preserved and no area to be removed, then the user has to specify newWidth.
  • It’s recommended to draw the mask over the area to be removed from top to bottom of the image a little larger than the area to be removed. This does not always hold true but it’s a good practice to follow.
  • It’s also recommended to make the mask wide enough to force the downscaling to be only in the remove area. This does not always hold true but it’s a good practice to follow.
  • This command does not support signed data images.
  • This command does not support 32-bit grayscale images.

Inheritance Hierarchy

System.Object
   Leadtools.ImageProcessing.RasterCommand
      Leadtools.ImageProcessing.SpecialEffects.IntelligentDownScaleCommand

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also