←Select platform

PaintGamma Property

Summary

Gets or sets the current gamma correction value for the image.

Syntax

C#
VB
Java
Objective-C
WinRT C#
C++
public int PaintGamma { get; set; } 
Public Property PaintGamma As Integer 
public int PaintGamma {get; set;} 
@property (nonatomic, assign) NSUInteger paintGamma 
public int getPaintGamma() 
public void setPaintGamma(int value) 
             
 <br/>get_PaintGamma();<br/>set_PaintGamma(value);<br/>Object.defineProperty('PaintGamma');  
public: 
property int PaintGamma { 
   int get(); 
   void set (    int ); 
} 

Property Value

The current gamma correction value.

Remarks

The paint gamma value can be any number greater than 0. The default value is 100.

Because this is an unsigned integer, it is 100 times the actual gamma value. For example, use 235 to set a gamma value of 2.35. Intensity values ideally follow a logarithmic progression, because the eye perceives changes in intensity as being equal when the ratio of change is equal. For example, we would see a change from 0.1 to 0.2 as being equal to a change from 0.2 to 0.4.

Gamma is a standard constant that is used to calculate the progression. For most CRTs the gamma constant is in the range of 2.2 to 2.5.

For more information, refer to Changing Brightness and Contrast.

Example

C#
VB
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 LeadtoolsExamples.Common; 
using Leadtools.Svg; 
 
public void IntensityExample() 
{ 
   IntensityForm f = new IntensityForm(); 
   f.ShowDialog(); 
} 
 
class IntensityForm : Form 
{ 
   ImageViewer viewer; 
   TrackBar gammaTrackBar; 
   TrackBar contrastTrackBar; 
   TrackBar intensityTrackBar; 
 
   public IntensityForm() 
   { 
      // Create the controls 
      Size = new Size(800, 600); 
      Panel controlsPanel = new Panel(); 
      controlsPanel.Size = new Size(400, 0); 
      controlsPanel.BorderStyle = BorderStyle.Fixed3D; 
      controlsPanel.Dock = DockStyle.Left; 
 
      int labelLeft = 8; 
      int y = 16; 
      int trackBarLeft = 100; 
 
      Label gammaLabel = new Label(); 
      gammaLabel.Text = "Gamma:"; 
      gammaLabel.Location = new Point(labelLeft, y); 
      gammaLabel.AutoSize = true; 
      controlsPanel.Controls.Add(gammaLabel); 
 
      gammaTrackBar = new TrackBar(); 
      gammaTrackBar.Minimum = 1; 
      gammaTrackBar.Maximum = 100; 
      gammaTrackBar.TickFrequency = (gammaTrackBar.Maximum - gammaTrackBar.Minimum) / 10; 
      gammaTrackBar.Location = new Point(trackBarLeft, y); 
      gammaTrackBar.Width = 200; 
      gammaTrackBar.Scroll += new EventHandler(gammaTrackBar_Scroll); 
      controlsPanel.Controls.Add(gammaTrackBar); 
      gammaLabel.Top = gammaTrackBar.Top + (gammaTrackBar.Height - gammaLabel.Height) / 2; 
      y = gammaTrackBar.Bottom + 8; 
 
      Label contrastLabel = new Label(); 
      contrastLabel.Text = "Contrast:"; 
      contrastLabel.Location = new Point(labelLeft, y); 
      contrastLabel.AutoSize = true; 
      controlsPanel.Controls.Add(contrastLabel); 
 
      contrastTrackBar = new TrackBar(); 
      contrastTrackBar.Minimum = -1000; 
      contrastTrackBar.Maximum = 1000; 
      contrastTrackBar.TickFrequency = (contrastTrackBar.Maximum - contrastTrackBar.Minimum) / 10; 
      contrastTrackBar.Location = new Point(trackBarLeft, y); 
      contrastTrackBar.Width = 200; 
      contrastTrackBar.Scroll += new EventHandler(contrastTrackBar_Scroll); 
      controlsPanel.Controls.Add(contrastTrackBar); 
      contrastLabel.Top = contrastTrackBar.Top + (contrastTrackBar.Height - contrastLabel.Height) / 2; 
      y = contrastTrackBar.Bottom + 8; 
 
      Label intensityLabel = new Label(); 
      intensityLabel.Text = "Intensity:"; 
      intensityLabel.Location = new Point(labelLeft, y); 
      intensityLabel.AutoSize = true; 
      controlsPanel.Controls.Add(intensityLabel); 
      y = intensityLabel.Bottom + 8; 
 
      intensityTrackBar = new TrackBar(); 
      intensityTrackBar.Minimum = -1000; 
      intensityTrackBar.Maximum = 1000; 
      intensityTrackBar.TickFrequency = (intensityTrackBar.Maximum - intensityTrackBar.Minimum) / 10; 
      intensityTrackBar.Location = new Point(trackBarLeft, y); 
      intensityTrackBar.Width = 200; 
      intensityTrackBar.Scroll += new EventHandler(intensityTrackBar_Scroll); 
      controlsPanel.Controls.Add(intensityTrackBar); 
      intensityLabel.Top = intensityTrackBar.Top + (intensityTrackBar.Height - intensityLabel.Height) / 2; 
      y = intensityTrackBar.Bottom + 8; 
 
      Button defaultButton = new Button(); 
      defaultButton.Text = "Default"; 
      defaultButton.Location = new Point(labelLeft, y); 
      defaultButton.Click += new EventHandler(defaultButton_Click); 
      controlsPanel.Controls.Add(defaultButton); 
 
      Controls.Add(controlsPanel); 
 
      viewer = new ImageViewer(); 
      viewer.Dock = DockStyle.Fill; 
      Controls.Add(viewer); 
      viewer.BringToFront(); 
 
      // Load the image 
      using (RasterCodecs codecs = new RasterCodecs()) 
      { 
         string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp"); 
         viewer.Image = codecs.Load(srcFileName); 
      } 
 
      gammaTrackBar.Value = viewer.Image.PaintGamma; 
      contrastTrackBar.Value = viewer.Image.PaintContrast; 
      intensityTrackBar.Value = viewer.Image.PaintIntensity; 
      UpdateValues(); 
   } 
 
   void UpdateValues() 
   { 
      string str = string.Format( 
         "Gamma = {0}, Contrast = {1}, Intensity = {2}", 
         viewer.Image.PaintGamma, viewer.Image.PaintContrast, viewer.Image.PaintIntensity); 
      Text = str; 
   } 
 
   void gammaTrackBar_Scroll(object sender, EventArgs e) 
   { 
      TrackBar tb = sender as TrackBar; 
      viewer.Image.PaintGamma = tb.Value; 
      UpdateValues(); 
   } 
 
   void contrastTrackBar_Scroll(object sender, EventArgs e) 
   { 
      TrackBar tb = sender as TrackBar; 
      viewer.Image.PaintContrast = tb.Value; 
      UpdateValues(); 
   } 
 
   void intensityTrackBar_Scroll(object sender, EventArgs e) 
   { 
      TrackBar tb = sender as TrackBar; 
      viewer.Image.PaintIntensity = tb.Value; 
      UpdateValues(); 
   } 
 
   void defaultButton_Click(object sender, EventArgs e) 
   { 
      viewer.Image.PaintGamma = 100; 
      viewer.Image.PaintIntensity = 0; 
      viewer.Image.PaintContrast = 0; 
 
      gammaTrackBar.Value = viewer.Image.PaintGamma; 
      contrastTrackBar.Value = viewer.Image.PaintContrast; 
      intensityTrackBar.Value = viewer.Image.PaintIntensity; 
 
      UpdateValues(); 
   } 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Core 
Imports Leadtools.ImageProcessing.Color 
Imports Leadtools.Controls 
Imports Leadtools.Dicom 
Imports Leadtools.Drawing 
Imports Leadtools.Svg 
 
Public Sub IntensityExample() 
   Dim f As IntensityForm = New IntensityForm() 
   f.ShowDialog() 
End Sub 
 
Private Class IntensityForm : Inherits Form 
   Private viewer As ImageViewer 
   Private gammaTrackBar As TrackBar 
   Private contrastTrackBar As TrackBar 
   Private intensityTrackBar As TrackBar 
 
   Public Sub New() 
      ' Create the controls 
      Size = New Size(800, 600) 
      Dim controlsPanel As Panel = New Panel() 
      controlsPanel.Size = New Size(400, 0) 
      controlsPanel.BorderStyle = BorderStyle.Fixed3D 
      controlsPanel.Dock = DockStyle.Left 
 
      Dim labelLeft As Integer = 8 
      Dim y As Integer = 16 
      Dim trackBarLeft As Integer = 100 
 
      Dim gammaLabel As Label = New Label() 
      gammaLabel.Text = "Gamma:" 
      gammaLabel.Location = New Point(labelLeft, y) 
      gammaLabel.AutoSize = True 
      controlsPanel.Controls.Add(gammaLabel) 
 
      gammaTrackBar = New TrackBar() 
      gammaTrackBar.Minimum = 1 
      gammaTrackBar.Maximum = 100 
      gammaTrackBar.TickFrequency = (gammaTrackBar.Maximum - gammaTrackBar.Minimum) \ 10 
      gammaTrackBar.Location = New Point(trackBarLeft, y) 
      gammaTrackBar.Width = 200 
      AddHandler gammaTrackBar.Scroll, AddressOf gammaTrackBar_Scroll 
      controlsPanel.Controls.Add(gammaTrackBar) 
      gammaLabel.Top = gammaTrackBar.Top + (gammaTrackBar.Height - gammaLabel.Height) \ 2 
      y = gammaTrackBar.Bottom + 8 
 
      Dim contrastLabel As Label = New Label() 
      contrastLabel.Text = "Contrast:" 
      contrastLabel.Location = New Point(labelLeft, y) 
      contrastLabel.AutoSize = True 
      controlsPanel.Controls.Add(contrastLabel) 
 
      contrastTrackBar = New TrackBar() 
      contrastTrackBar.Minimum = -1000 
      contrastTrackBar.Maximum = 1000 
      contrastTrackBar.TickFrequency = (contrastTrackBar.Maximum - contrastTrackBar.Minimum) \ 10 
      contrastTrackBar.Location = New Point(trackBarLeft, y) 
      contrastTrackBar.Width = 200 
      AddHandler contrastTrackBar.Scroll, AddressOf contrastTrackBar_Scroll 
      controlsPanel.Controls.Add(contrastTrackBar) 
      contrastLabel.Top = contrastTrackBar.Top + (contrastTrackBar.Height - contrastLabel.Height) \ 2 
      y = contrastTrackBar.Bottom + 8 
 
      Dim intensityLabel As Label = New Label() 
      intensityLabel.Text = "Intensity:" 
      intensityLabel.Location = New Point(labelLeft, y) 
      intensityLabel.AutoSize = True 
      controlsPanel.Controls.Add(intensityLabel) 
      y = intensityLabel.Bottom + 8 
 
      intensityTrackBar = New TrackBar() 
      intensityTrackBar.Minimum = -1000 
      intensityTrackBar.Maximum = 1000 
      intensityTrackBar.TickFrequency = (intensityTrackBar.Maximum - intensityTrackBar.Minimum) \ 10 
      intensityTrackBar.Location = New Point(trackBarLeft, y) 
      intensityTrackBar.Width = 200 
      AddHandler intensityTrackBar.Scroll, AddressOf intensityTrackBar_Scroll 
      controlsPanel.Controls.Add(intensityTrackBar) 
      intensityLabel.Top = intensityTrackBar.Top + (intensityTrackBar.Height - intensityLabel.Height) \ 2 
      y = intensityTrackBar.Bottom + 8 
 
      Dim defaultButton As Button = New Button() 
      defaultButton.Text = "Default" 
      defaultButton.Location = New Point(labelLeft, y) 
      AddHandler defaultButton.Click, AddressOf defaultButton_Click 
      controlsPanel.Controls.Add(defaultButton) 
 
      Controls.Add(controlsPanel) 
 
      viewer = New ImageViewer() 
      viewer.Dock = DockStyle.Fill 
      Controls.Add(viewer) 
      viewer.BringToFront() 
 
      ' Load the image 
      Using codecs As RasterCodecs = New RasterCodecs() 
 
         Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp") 
         viewer.Image = codecs.Load(srcFileName) 
 
      End Using 
 
      gammaTrackBar.Value = viewer.Image.PaintGamma 
      contrastTrackBar.Value = viewer.Image.PaintContrast 
      intensityTrackBar.Value = viewer.Image.PaintIntensity 
      UpdateValues() 
   End Sub 
 
   Private Sub UpdateValues() 
      Dim str As String = String.Format("Gamma = {0}, Contrast = {1}, Intensity = {2}", viewer.Image.PaintGamma, viewer.Image.PaintContrast, viewer.Image.PaintIntensity) 
      Text = str 
   End Sub 
 
   Private Sub gammaTrackBar_Scroll(ByVal sender As Object, ByVal e As EventArgs) 
      Dim tb As TrackBar = CType(IIf(TypeOf sender Is TrackBar, sender, Nothing), TrackBar) 
      viewer.Image.PaintGamma = tb.Value 
      UpdateValues() 
   End Sub 
 
   Private Sub contrastTrackBar_Scroll(ByVal sender As Object, ByVal e As EventArgs) 
      Dim tb As TrackBar = CType(IIf(TypeOf sender Is TrackBar, sender, Nothing), TrackBar) 
      viewer.Image.PaintContrast = tb.Value 
      UpdateValues() 
   End Sub 
 
   Private Sub intensityTrackBar_Scroll(ByVal sender As Object, ByVal e As EventArgs) 
      Dim tb As TrackBar = CType(IIf(TypeOf sender Is TrackBar, sender, Nothing), TrackBar) 
      viewer.Image.PaintIntensity = tb.Value 
      UpdateValues() 
   End Sub 
 
   Private Sub defaultButton_Click(ByVal sender As Object, ByVal e As EventArgs) 
      viewer.Image.PaintGamma = 100 
      viewer.Image.PaintIntensity = 0 
      viewer.Image.PaintContrast = 0 
 
      gammaTrackBar.Value = viewer.Image.PaintGamma 
      contrastTrackBar.Value = viewer.Image.PaintContrast 
      intensityTrackBar.Value = viewer.Image.PaintIntensity 
 
      UpdateValues() 
   End Sub 
End Class 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.19
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly