LEADTOOLS(Leadtoolsアセンブリ)

フレームを表示

SetLookupTableなメソッド








このRasterImageのルックアップテーブル(LUT)を表すRasterColor構造体の配列。
このRasterImageの8ビットルックアップテーブル(LUT)を設定します。
構文
public void SetLookupTable( 
   RasterColor[] value
)
'Declaration
 
Public Sub SetLookupTable( _
   ByVal value() As RasterColor _
) 
'Usage
 
Dim instance As RasterImage
Dim value() As RasterColor
 
instance.SetLookupTable(value)
public void SetLookupTable( 
   RasterColor[] value
)
- (BOOL)setLookupTable:(nullable NSArray<LTRasterColor *> *)lut error:(NSError **)error
public void setLookupTable(RasterColor[] value)
 function Leadtools.RasterImage.SetLookupTable( 
   value 
)
public:
void SetLookupTable( 
   array<RasterColor>^ value
) 

パラメーター

このRasterImageのルックアップテーブル(LUT)を表すRasterColor構造体の配列。
解説

UseLookupTableの値がtrueに設定されるとき、ルックアップテーブル(LUT)が使われます。

1を変更するように、8ビットで16ビットのルックアップテーブルは同期しますよくそれが推薦されるように16ビットのルックアップテーブル(SetLookupTable16)がより多くの精度を持っていて、他が変更されて、8ビットLUTの代わりに16ビットのLUTを使います。

LUTが、10-16ビット拡張グレースケールimageまたは10-16ビットパレットカラーimageのために使われるだけです。1-8のビットイメージの中でパレットを更新するために、SetPaletteを使います。詳細については、「グレースケールイメージ」を参照してください。

LUTも、保存されるビットが16ビットの、そして、LUTが色値を格納して、そのような拡張パレットカラーimageを示すために、使われます。これは、極端なサウンドimageで一般的です。

サンプル
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

      
Private Sub SetLookupTable()
   DicomEngine.Startup()
   ' Get the path of the LEADTOOLS images directory
   Dim strImagesDirectory As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "//LEADTOOLS Images//"

   ' Create a RasterCodecs class for saving out images
   Dim codecs As RasterCodecs = New RasterCodecs()

   ' Load a dataset
   Dim ds As DicomDataSet = New DicomDataSet()
   ds.Load(strImagesDirectory & "IMAGE3.dcm", DicomDataSetLoadFlags.None)

   ' Get the image but do NOT auto-apply any of the LUTs
   Dim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PixelData, True)
   Dim image As RasterImage = ds.GetImage(element, 0, 16, RasterByteOrder.Gray, DicomGetImageFlags.None)
   image.UseLookupTable = True

   ' Save out the image without any LUTs applied.  It should be black
   codecs.Save(image, strImagesDirectory & "BeforeSetLookupTable.bmp", RasterImageFormat.Bmp, 8)

   ' Create a LUT
   Dim lut As RasterColor() = New RasterColor(CInt(Math.Pow(2, 16)) - 1) {}

   ' Get the Minimum and Maximum values so we can calculate appropriate LUT values.
   Dim cmdMinMax As MinMaxValuesCommand = New MinMaxValuesCommand()
   cmdMinMax.Run(image)
   Dim maxVal As Integer = cmdMinMax.MaximumValue
   Dim minVal As Integer = cmdMinMax.MinimumValue

   Dim i As Integer = 0
   Do While i < lut.Length
      lut(i).R = Convert.ToByte(Math.Min(255, ((i - minVal) * 255 / (maxVal - minVal))))
      lut(i).G = lut(i).R
      lut(i).B = lut(i).R
      i += 1
   Loop

   ' Set the new lookup table
   image.SetLookupTable(lut)

   ' Save out the image with the LUT applied.  It should look normal
   codecs.Save(image, strImagesDirectory & "AfterSetLookupTable.bmp", RasterImageFormat.Bmp, 8)

   DicomEngine.Shutdown()
End Sub
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 SetLookupTable()
{
   DicomEngine.Startup();
   // Create a RasterCodecs class for saving out images
   RasterCodecs codecs = new RasterCodecs();

   // Load a dataset
   DicomDataSet ds = new DicomDataSet();
   ds.Load(Path.Combine(ImagesPath.Path, "IMAGE3.dcm"), DicomDataSetLoadFlags.None);

   // Get the image but do NOT auto-apply any of the LUTs
   DicomElement element = ds.FindFirstElement(null, DicomTag.PixelData, true);
   RasterImage image = ds.GetImage(element, 0, 16, RasterByteOrder.Gray, DicomGetImageFlags.None);
   image.UseLookupTable = true;

   // Save out the image without any LUTs applied.  It should be black
   codecs.Save(image, Path.Combine(ImagesPath.Path, "BeforeSetLookupTable.bmp"), RasterImageFormat.Bmp, 8);

   // Create a LUT
   RasterColor[] lut = new RasterColor[(int)Math.Pow(2, 16)];

   // Get the Minimum and Maximum values so we can calculate appropriate LUT values.
   MinMaxValuesCommand cmdMinMax = new MinMaxValuesCommand();
   cmdMinMax.Run(image);
   int maxVal = cmdMinMax.MaximumValue;
   int minVal = cmdMinMax.MinimumValue;

   for(int i = 0; i < lut.Length; i++)
   {
      lut[i].R = Convert.ToByte(Math.Min(255, ((i - minVal) * 255 / (maxVal - minVal))));
      lut[i].G = lut[i].R;
      lut[i].B = lut[i].R;
   }

   // Set the new lookup table
   image.SetLookupTable(lut);

   // Save out the image with the LUT applied.  It should look normal
   codecs.Save(image, Path.Combine(ImagesPath.Path, "AfterSetLookupTable.bmp"), RasterImageFormat.Bmp, 8);

   DicomEngine.Shutdown();
}
RasterImageExamples.prototype.SetLookupTable = function ( ) 
{
   Tools.SetLicense ( ) ;

   with (Leadtools) {
      with (Leadtools.Codecs) {
         with (Leadtools.Dicom) {
            DicomEngine.startup();

            // Create a RasterCodecs class for saving out images
            var codecs = new RasterCodecs();
            var image;
            // Load a dataset
            var ds = new DicomDataSet();
            var srcFileName = "Assets\\IMAGE3.dcm";
            return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
               return ds.loadAsync(LeadStreamFactory.create(loadFile), DicomDataSetLoadFlags.none)})
                  .then(function () {

                     // Get the image but do NOT auto-apply any of the LUTs
                     var element = ds.findFirstElement(null, Leadtools.Dicom.Constants.DicomTagConstants.pixel_DATA, true);
                     image = ds.getImage(element, 0, 16, DicomGetImageFlags.none);
                     image.useLookupTable = true;

                     // Save out the image without any LUTs applied.  It should be black
                     return Tools.AppLocalFolder().createFileAsync("BeforeSetLookupTable.bmp")
                  })
                  .then(function (saveFile) {
                     var saveStream = LeadStreamFactory.create(saveFile);
                     return codecs.saveAsync(image, saveStream, RasterImageFormat.bmp, 8)
                  })
                  .then(function () {

                     // Create a LUT
                     var lut = new Array(Math.pow(2, 16));

                     // Get the Minimum and Maximum values so we can calculate appropriate LUT values.
                     var cmdMinMax = new Leadtools.ImageProcessing.Core.MinMaxValuesCommand();
                     cmdMinMax.run(image);
                     var maxVal = cmdMinMax.maximumValue;
                     var minVal = cmdMinMax.minimumValue;

                     for (var i = 0; i < lut.length; i++) {
                        var color = {};

                        color.a = 255;
                        color.reserved = 0;
                        color.r = Math.max(0, (Math.min(255, ((i - minVal) * 255 / (maxVal - minVal)))));
                        color.g = color.r;
                        color.b = color.r;
                        lut[i] = color;
                     }

                     // Set the new lookup table
                     image.setLookupTable(lut);

                     // Save out the image with the LUT applied.  It should look normal
                     return Tools.AppLocalFolder().createFileAsync("AfterSetLookupTable.bmp")
                  })
                  .then(function (saveFile) {
                     saveStream = LeadStreamFactory.create(saveFile);
                     return codecs.saveAsync(image, saveStream, RasterImageFormat.bmp, 0)
                  })
                  .then(function () {

                     DicomEngine.shutdown();
                  });
         }
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;

      
public async Task SetLookupTable()
{
   DicomEngine.Startup();
   // Create a RasterCodecs class for saving out images
   RasterCodecs codecs = new RasterCodecs();

   // Load a dataset
   DicomDataSet ds = new DicomDataSet();
   string srcFileName = @"Assets\IMAGE3.dcm";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   await ds.LoadAsync(LeadStreamFactory.Create(loadFile), DicomDataSetLoadFlags.None);

   // Get the image but do NOT auto-apply any of the LUTs
   DicomElement element = ds.FindFirstElement(null, Leadtools.Dicom.Constants.DicomTagConstants.PixelData, true);
   RasterImage image = ds.GetImage(element, 0, 16, DicomGetImageFlags.None);
   image.UseLookupTable = true;

   // Save out the image without any LUTs applied.  It should be black
   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync("BeforeSetLookupTable.bmp");
   ILeadStream saveStream = LeadStreamFactory.Create(saveFile);
   await codecs.SaveAsync(image, saveStream, RasterImageFormat.Bmp, 8);

   // Create a LUT
   RasterColor[] lut = new RasterColor[(int)Math.Pow(2, 16)];

   // Get the Minimum and Maximum values so we can calculate appropriate LUT values.
   MinMaxValuesCommand cmdMinMax = new MinMaxValuesCommand();
   cmdMinMax.Run(image);
   int maxVal = cmdMinMax.MaximumValue;
   int minVal = cmdMinMax.MinimumValue;

   for (int i = 0; i < lut.Length; i++)
   {
      lut[i].R = Convert.ToByte(Math.Min(255, ((i - minVal) * 255 / (maxVal - minVal))));
      lut[i].G = lut[i].R;
      lut[i].B = lut[i].R;
   }

   // Set the new lookup table
   image.SetLookupTable(lut);

   // Save out the image with the LUT applied.  It should look normal
   saveFile = await Tools.AppLocalFolder.CreateFileAsync("AfterSetLookupTable.bmp");
   saveStream = LeadStreamFactory.Create(saveFile);
   await codecs.SaveAsync(image, saveStream, RasterImageFormat.Bmp, 0);

   DicomEngine.Shutdown();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Dicom;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Examples;
using Leadtools.Windows.Media;

public void SetLookupTable(Stream dataSetStream, Stream destStream1, Stream destStream2)
{
   // Create a RasterCodecs class for saving out images
   RasterCodecs codecs = new RasterCodecs();
   // Load a dataset
   DicomDataSet ds = new DicomDataSet();
   ds.Load(dataSetStream, DicomDataSetLoadFlags.None);

   // Get the image but do NOT auto-apply any of the LUTs
   DicomElement element = ds.FindFirstElement(null, DicomTag.PixelData, true);
   RasterImage image = ds.GetImage(element, 0, 16, RasterByteOrder.Gray, DicomGetImageFlags.None);
   image.UseLookupTable = true;

   // Save out the image without any LUTs applied.  It should be black
   codecs.Save(image, destStream1, RasterImageFormat.Bmp, 8);

   // Create a LUT
   RasterColor[] lut = new RasterColor[(int)Math.Pow(2, 16)];

   // Get the Minimum and Maximum values so we can calculate appropriate LUT values.
   MinMaxValuesCommand cmdMinMax = new MinMaxValuesCommand();
   cmdMinMax.Run(image);
   int maxVal = cmdMinMax.MaximumValue;
   int minVal = cmdMinMax.MinimumValue;

   for (int i = 0; i < lut.Length; i++)
   {
      lut[i].R = Convert.ToByte(Math.Min(255, ((i - minVal) * 255 / (maxVal - minVal))));
      lut[i].G = lut[i].R;
      lut[i].B = lut[i].R;
   }

   // Set the new lookup table
   image.SetLookupTable(lut);

   // Save out the image with the LUT applied.  It should look normal
   codecs.Save(image, destStream2, RasterImageFormat.Bmp, 8);

   DicomEngine.Shutdown();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Dicom
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media

Public Sub SetLookupTable(ByVal dataSetStream As Stream, ByVal destStream1 As Stream, ByVal destStream2 As Stream)
   ' Create a RasterCodecs class for saving out images
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' Load a dataset
   Dim ds As DicomDataSet = New DicomDataSet()
   ds.Load(dataSetStream, DicomDataSetLoadFlags.None)

   ' Get the image but do NOT auto-apply any of the LUTs
   Dim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PixelData, True)
   Dim image As RasterImage = ds.GetImage(element, 0, 16, RasterByteOrder.Gray, DicomGetImageFlags.None)
   image.UseLookupTable = True

   ' Save out the image without any LUTs applied.  It should be black
   codecs.Save(image, destStream1, RasterImageFormat.Bmp, 8)

   ' Create a LUT
   Dim lut As RasterColor() = New RasterColor(CInt(Math.Pow(2, 16)) - 1){}

   ' Get the Minimum and Maximum values so we can calculate appropriate LUT values.
   Dim cmdMinMax As MinMaxValuesCommand = New MinMaxValuesCommand()
   cmdMinMax.Run(image)
   Dim maxVal As Integer = cmdMinMax.MaximumValue
   Dim minVal As Integer = cmdMinMax.MinimumValue

   Dim i As Integer = 0
   Do While i < lut.Length
      lut(i).R = Convert.ToByte(Math.Min(255, ((i - minVal) * 255 / (maxVal - minVal))))
      lut(i).G = lut(i).R
      lut(i).B = lut(i).R
      i += 1
   Loop

   ' Set the new lookup table
   image.SetLookupTable(lut)

   ' Save out the image with the LUT applied.  It should look normal
   codecs.Save(image, destStream2, RasterImageFormat.Bmp, 8)

   DicomEngine.Shutdown()
End Sub
必要条件

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

参照

参照

RasterImageクラス
RasterImageメンバ
Leadtools.Drawing.RasterPaintCallbacks
カスタム描画を実装すること