←Select platform

IntelligentDownScaleCommand Class

Summary

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.

Syntax
C#
VB
C++
public class IntelligentDownScaleCommand : RasterCommand 
  
Public Class IntelligentDownScaleCommand  
   Inherits RasterCommand 
public ref class IntelligentDownScaleCommand : public RasterCommand   

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.

Example
C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.SpecialEffects; 
 
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"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing.SpecialEffects 
 
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 

Requirements

Target Platforms

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

Leadtools.ImageProcessing.SpecialEffects Assembly