←Select platform

SharpenCommand Class

Summary
Increases or decreases the sharpness of a specific image.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public class SharpenCommand : RasterCommand 
@interface LTSharpenCommand : LTRasterCommand 
public class SharpenCommand 
    extends RasterCommand 
public ref class SharpenCommand : public RasterCommand   
class SharpenCommand(RasterCommand): 
Remarks
  • Negative sharpness values decrease the sharpness of the image. Specify -1000 for minimum sharpness. Positive sharpness values increase the sharpness. Specify +1000 for maximum sharpness.
  • This command supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.
  • This command does not support 32-bit grayscale images.
  • This command supports signed/unsigned data images.

For more information, refer to Detecting and Enhancing Edges and Lines.

Sharpen Function - Before

Sharpen Function - Before

Sharpen Function - After

Sharpen Function - After

View additional platform support for this Sharpen function.

Example

Run the SharpenCommand on an image and increases its sharpness.

C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Effects; 
 
 
public void SharpenCommandCommandExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP")); 
 
   // Prepare the command 
   SharpenCommand command = new SharpenCommand(); 
   //Increase the sharpness by 25 percent  of the possible range. 
   command.Sharpness = 950; 
   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:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.assertTrue; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.effects.*; 
 
 
public void sharpenCommandCommandExample() { 
 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.setThrowExceptionsOnInvalidImages(true); 
 
   RasterImage image = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "IMAGE1.CMP")); 
 
   // Prepare the command 
   SharpenCommand command = new SharpenCommand(); 
 
   // Increase the sharpness by 25 percent of the possible range. 
   command.setSharpness(950); 
   int change = command.run(image); 
   assertTrue(change != RasterImageChangedFlags.NONE); 
 
   // Save the image 
   String outputFileName = combine(LEAD_VARS_IMAGES_DIR, "sharpenResult.jpg"); 
   codecs.save(image, outputFileName, RasterImageFormat.JPEG, 24); 
   System.out.println("Command run, image saved to " + outputFileName); 
} 
Requirements

Target Platforms

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

Leadtools.ImageProcessing.Effects Assembly

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