←Select platform

MaxValue Property

Summary
Gets or sets the images maximum grayscale value.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int MaxValue { get; set; } 
@property (nonatomic, assign) NSInteger maxValue 
public int getMaxValue(); 
public void setMaxValue( 
   int intValue 
); 
public: 
property int MaxValue { 
   int get(); 
   void set (    int ); 
} 
MaxValue # get and set (RasterImage) 

Property Value

Maximum grayscale value.

Remarks

For every value between 0 and MinValue, Black (RGB(0,0,0)) will be used. For values between MinValue and MaxValue, the gray value to be displayed is calculated by : gray = (index - MinValue) * 255 / (MaxValue - MinValue).

index is the intensity value of the pixel. If the intensity value is > MaxValue, the color will be White. If the intensity value is < MinValue, the color will be Black. For those intensity values between MinValue and MaxValue, the above equation is used to determine the color, with index equal to the intensity value.

For more information, refer to Grayscale Images.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Dicom; 
using Leadtools.Drawing; 
using Leadtools.Controls; 
using Leadtools.Svg; 
 
 
public void WindowLevelExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
   // Load an image that has BottomLeft ViewPerspective 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP")); 
   Console.WriteLine("Values for 24-bit image:"); 
   Console.WriteLine($"MinValue = {image.MinValue}"); 
   Console.WriteLine($"MaxValue = {image.MaxValue}"); 
   Console.WriteLine($"PaintLowBit = {image.PaintLowBit}"); 
   Console.WriteLine($"PaintHighBit = {image.PaintHighBit}"); 
 
   // Change the image to 16-bit grayscale  
   GrayscaleCommand grayscaleCmd = new GrayscaleCommand(16); 
   grayscaleCmd.Run(image); 
 
   Console.WriteLine("Values for 16-bit grayscale image:"); 
   Console.WriteLine($"MinValue = {image.MinValue}"); 
   Console.WriteLine($"MaxValue = {image.MaxValue}"); 
   Console.WriteLine($"PaintLowBit = {image.PaintLowBit}"); 
   Console.WriteLine($"PaintHighBit = {image.PaintHighBit}"); 
 
   MinMaxBitsCommand minMaxBitsCmd = new MinMaxBitsCommand(); 
   minMaxBitsCmd.Run(image); 
 
   MinMaxValuesCommand minMaxValuesCmd = new MinMaxValuesCommand(); 
   minMaxValuesCmd.Run(image); 
 
   int lowBit = minMaxBitsCmd.MinimumBit; 
   int highBit = minMaxBitsCmd.MaximumBit; 
 
   int size = (1 << (image.HighBit - image.LowBit + 1)); 
   RasterColor[] palette = new RasterColor[size]; 
 
   // fill the first half of the LUT with RED 
   for (int x = 0; x < size / 2; x++) 
   { 
      palette[x].R = 255; 
      palette[x].G = 0; 
      palette[x].B = 0; 
      palette[x].Reserved = 0; 
   } 
 
   int minVal = minMaxValuesCmd.MinimumValue; 
   int maxVal = minMaxValuesCmd.MaximumValue; 
 
   // Fill the rest with gray values  
   for (int x = (size / 2); x < size; x++) 
   { 
      palette[x].R = Convert.ToByte(Math.Min(255, ((x - minVal) * 255 / (maxVal - minVal)))); 
      palette[x].G = palette[x].R; 
      palette[x].B = palette[x].R; 
      palette[x].Reserved = 0; 
   } 
   image.WindowLevel(lowBit, highBit, palette, RasterWindowLevelMode.PaintAndProcessing); 
 
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_WindowLevel.BMP"), RasterImageFormat.Bmp, 0); 
 
   image.Dispose(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

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

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