←Select platform

Threshold Property

Summary
Gets or sets the maximum pixel value to be colored using the Color property.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int Threshold { get; set; } 
@property (nonatomic, assign) NSUInteger threshold; 
public int getThreshold(); 
public void setThreshold( 
   int intValue 
); 
public: 
property int Threshold { 
   int get(); 
   void set (    int ); 
} 
Threshold # get and set (ColorizeGrayCommandData) 

Property Value

The maximum pixel value to be colored using the Color property. The pixels with a value less than or equal to this will have the color set in the Color property. If the ColorizeGrayCommandData class is the last in the GrayColors array, then this value is ignored and the maximum possible value will be used instead. The maximum value depends on the image bits per pixel. For 8, 12 and 16-bit images the maximum value is 255, 4095 and 65535 respectively. However if you enter a value higher than the maximum, the value will be clipped at the maximum value.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
 
public void ColorizeGrayCommandExample() 
{ 
   // Load an image 
 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\Beauty16.jpg")); 
 
   // Prepare the command 
   ColorizeGrayCommandData[] pGrayColors = new ColorizeGrayCommandData[6]; 
   for (int i = 0; i < 6; i++) 
      pGrayColors[i] = new ColorizeGrayCommandData(); 
   pGrayColors[0].Threshold = 9999; 
   pGrayColors[1].Threshold = 19999; 
   pGrayColors[2].Threshold = 29999; 
   pGrayColors[3].Threshold = 39999; 
   pGrayColors[4].Threshold = 49999; 
   pGrayColors[5].Threshold = 59999; 
 
   pGrayColors[0].Color = new RasterColor(255, 0, 0); 
   pGrayColors[1].Color = new RasterColor(0, 255, 0); 
   pGrayColors[2].Color = new RasterColor(0, 0, 255); 
   pGrayColors[3].Color = new RasterColor(0, 255, 255); 
   pGrayColors[4].Color = new RasterColor(255, 0, 255); 
   pGrayColors[5].Color = new RasterColor(255, 255, 0); 
 
   ColorizeGrayCommand command = new ColorizeGrayCommand(); 
   command.GrayColors = pGrayColors; 
   //Call the command 
   command.Run(image); 
 
   // Save the resulted image 
   codecs.Save(command.DestinationImage, Path.Combine(LEAD_VARS.ImagesDir, "ColorizeGrayResult.Bmp"), RasterImageFormat.Bmp, 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.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.core.*; 
 
 
public void colorizeGrayCommandExample() { 
 
   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, "beauty16.jpg")); 
 
   // Prepare the command 
   ColorizeGrayCommandData[] pGrayColors = new ColorizeGrayCommandData[6]; 
   for (int index = 0; index < 6; index++) { 
      pGrayColors[index] = new ColorizeGrayCommandData(); 
   } 
   pGrayColors[0].setThreshold(9999); 
   pGrayColors[1].setThreshold(19999); 
   pGrayColors[2].setThreshold(29999); 
   pGrayColors[3].setThreshold(39999); 
   pGrayColors[4].setThreshold(49999); 
   pGrayColors[5].setThreshold(59999); 
 
   pGrayColors[0].setColor(new RasterColor(255, 0, 0)); 
   pGrayColors[1].setColor(new RasterColor(0, 255, 0)); 
   pGrayColors[2].setColor(new RasterColor(0, 0, 255)); 
   pGrayColors[3].setColor(new RasterColor(0, 255, 255)); 
   pGrayColors[4].setColor(new RasterColor(255, 0, 255)); 
   pGrayColors[5].setColor(new RasterColor(255, 255, 0)); 
 
   ColorizeGrayCommand command = new ColorizeGrayCommand(); 
   command.setGrayColors(pGrayColors); 
   // Call the command 
   command.run(image); 
 
   // Save the resulted image 
   codecs.save(command.getDestinationImage(), combine(LEAD_VARS_IMAGES_DIR, "ColorizeGrayResult.Bmp"), 
         RasterImageFormat.BMP, 24); 
 
   System.out.println("Command run and image saved to " + combine(LEAD_VARS_IMAGES_DIR, "ColorizeGrayResult.Bmp")); 
   assertTrue(new File(combine(LEAD_VARS_IMAGES_DIR, "ColorizeGrayResult.Bmp")).exists()); 
} 
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.Core Assembly

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