LEADTOOLS(Leadtoolsアセンブリ)

フレームを表示

PaintGammaプロパティ








imageのために現在のガンマ補正値を取得または設定します。
構文
public int PaintGamma {get; set;}
'Declaration
 
Public Property PaintGamma As Integer
'Usage
 
Dim instance As RasterImage
Dim value As Integer
 
instance.PaintGamma = value
 
value = instance.PaintGamma
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 value);
}

属性値

現在のガンマ補正値。
解説

描画ガンマ値は、0より大きい任意の数でありえます。デフォルト値は、100です。

これが符号のない整数であるので、それは実際のガンマ値の100倍です。たとえば、2.35のガンマ値を設定するために、235を使います。輝度の後は対数数列が続くのが理想です。変化の比率が同じであるとき、眼は輝度の変化が等しいと気づくためです。たとえば、0.1から0.2への変化は、0.2から0.4への変化と同じであるように見えます。

Gammaは、数列を計算するのに用いられる標準的な定数です。大部分のCRTのために、ガンマ定数は、2.2~2.5の範囲にあります。

詳細については、「明度とコントラストの変更」を参照してください。

サンプル
Copy Code  
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
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 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();
   }
}
必要条件

ターゲットプラットホーム

参照

参照

RasterImageクラス
RasterImageメンバ