←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#
C++/CLI
Python
public class IntelligentDownScaleCommand : RasterCommand 
public ref class IntelligentDownScaleCommand : public RasterCommand   
class IntelligentDownScaleCommand(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 is 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 is a good practice to follow.
  • It is 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 is a good practice to follow.
  • This command does not support signed data images.
  • This command does not support 32-bit grayscale images.

Intelligent Down Scale Function - Before

Intelligent Down Scale Function - Before

Intelligent Down Scale Function - After

Intelligent Down Scale Function - After

View additional platform support for this Intelligent Down Scale function.

Example
C#
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:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

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

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