LEADTOOLS(Leadtoolsアセンブリ)

フレームを表示

ClearNegativePixelsCommandクラス








メンバ 
0まで負の色値ですべてのピクセルを設定します。
オブジェクトモデル
構文
public class ClearNegativePixelsCommand : RasterCommand, IRasterCommand  
'Declaration
 
Public Class ClearNegativePixelsCommand 
   Inherits RasterCommand
   Implements IRasterCommand 
'Usage
 
Dim instance As ClearNegativePixelsCommand
public sealed class ClearNegativePixelsCommand : IRasterCommand  
@interface LTClearNegativePixelsCommand : LTRasterCommand
public class ClearNegativePixelsCommand extends RasterCommand
function Leadtools.ImageProcessing.ClearNegativePixelsCommand()
public ref class ClearNegativePixelsCommand : public RasterCommand, IRasterCommand  
解説

ファイルがロードされるときCodecsLoadOptions.Signedがtrueであるならば、imageは負のピクセル値を格納するかもしれません、そして、LEADTOOLSは誤ってimageを描画して/処理します。正しくこのimageを使うために、必要なものユーザーClearNegativePixelsCommandです。CodecsLoadOptions.Signedプロパティがfalseであるならば、ロードプロセスの間に、すべての負のピクセルは内部的にクリアされます。

何通かのTIFFファイルがピクセルカラーのために負の数で保存されるため、imageをロードした後に、RasterImage.Signedがtrueであるならば、ClearNegativePixelsCommandを使わなければなりません。RasterImage.IsSignedがfalseであるならば、ClearNegativePixelsCommandは何もしません。

プログラミングについての情報:ファイルからimageをロードすることの直後に、ClearNegativePixelsCommandを使います。

詳細については、「LEADTOOLSによる画像処理入門」を参照してください。

サンプル

このサンプルはロードオプションで符合付きフラグを設定して、tifファイルをロードして、負のピクセルをクリアします。

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing

      
Public Sub ClearNegativePixelsCommandExample()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
   Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "CleanNegativePixelsCommand.tif")

   ' Load the CMP file and convert it to TIF
   Dim image As RasterImage = codecs.Load(srcFileName)
   image.Signed = True
   codecs.Save(image, destFileName, RasterImageFormat.Tif, 24)
   image.Dispose()

   ' Load this image as signed
   codecs.Options.Load.Signed = True

   ' Load the source image from disk
   image = codecs.Load(destFileName)
   Debug.Assert(image.Signed)

   ' Clear the negative pixels and save it it back
   Dim command As ClearNegativePixelsCommand = New ClearNegativePixelsCommand()
   command.Run(image)
   Debug.Assert((Not image.Signed))

   codecs.Save(image, destFileName, RasterImageFormat.Tif, 24)

   ' Clean up
   image.Dispose()
End Sub

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;

      
public void ClearNegativePixelsCommandExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");
   string destFileName = Path.Combine(ImagesPath.Path, "CleanNegativePixelsCommand.tif");

   // Load the CMP file and convert it to TIF
   RasterImage image = codecs.Load(srcFileName);
   image.Signed = true;
   codecs.Save(image, destFileName, RasterImageFormat.Tif, 24);
   image.Dispose();

   // Load this image as signed
   codecs.Options.Load.Signed = true;

   // Load the source image from disk
   image = codecs.Load(destFileName);
   Assert.IsTrue(image.Signed);

   // Clear the negative pixels and save it it back
   ClearNegativePixelsCommand command = new ClearNegativePixelsCommand();
   command.Run(image);
   Assert.IsTrue(!image.Signed);

   codecs.Save(image, destFileName, RasterImageFormat.Tif, 24);

   // Clean up
   image.Dispose();
   codecs.Dispose();
}
RasterCommandExamples.prototype.ClearNegativePixelsCommandExample = function () {
    Tools.SetLicense();
    with (Leadtools) {
        with (Leadtools.Codecs) {
            var codecs = new RasterCodecs();

            var srcFileName = "Assets\\Image1.cmp";
            var destFileName1 = "CleanNegativePixelsCommand1.tif";
            var destFileName2 = "CleanNegativePixelsCommand2.tif";
            var image;
            // Load the CMP file and convert it to TIF
            return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
                return codecs.loadAsync(LeadStreamFactory.create(loadFile), 24, CodecsLoadByteOrder.bgr, 1, 1)
            })
                    .then(function (img) {
                        image = img;

                        image.signed = true;

                        return Tools.AppLocalFolder().createFileAsync(destFileName1)
                    })
                    .then(function (saveFile) {
                        return codecs.saveAsync(image, LeadStreamFactory.create(saveFile), RasterImageFormat.tif, 24)
                    })
                    .then(function () {

                        image.close();

                        // Load this image as signed
                        codecs.options.load.signed = true;

                        // Load the source image from disk
                        return Tools.AppLocalFolder().getFileAsync(destFileName1)
                    })
                    .then(function (loadFile) {
                        return codecs.loadAsync(LeadStreamFactory.create(loadFile), 24, CodecsLoadByteOrder.bgr, 1, 1)
                    })
                    .then(function (img) {
                        image = img;
                        console.assert(image.signed);

                        // Clear the negative pixels and save it it back
                        var command = new Leadtools.ImageProcessing.ClearNegativePixelsCommand();
                        command.run(image);
                        console.assert(!image.signed, "!image.signed");

                        return Tools.AppLocalFolder().createFileAsync(destFileName2)
                    })
                    .then(function (saveFile) {
                        return codecs.saveAsync(image, LeadStreamFactory.create(saveFile), RasterImageFormat.tif, 24)
                    })
                    .then(function () {
                        // Clean up
                        image.close();
                        codecs.close;
                    });
        }
    }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;

      
public async Task ClearNegativePixelsCommandExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = @"Assets\Image1.cmp";
   string destFileName1 = @"CleanNegativePixelsCommand1.tif";
   string destFileName2 = @"CleanNegativePixelsCommand2.tif";

   // Load the CMP file and convert it to TIF
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile), 24, CodecsLoadByteOrder.Bgr, 1, 1);

   image.Signed = true;

   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName1);
   await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), RasterImageFormat.Tif, 24);

   image.Dispose();

   // Load this image as signed
   codecs.Options.Load.Signed = true;

   // Load the source image from disk
   loadFile = await Tools.AppLocalFolder.GetFileAsync(destFileName1);
   image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile), 24, CodecsLoadByteOrder.Bgr, 1, 1);
   Assert.IsTrue(image.Signed);

   // Clear the negative pixels and save it it back
   ClearNegativePixelsCommand command = new ClearNegativePixelsCommand();
   command.Run(image);
   Assert.IsTrue(!image.Signed);

   saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName2);
   await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), RasterImageFormat.Tif, 24);

   // Clean up
   image.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;
using Leadtools.Windows.Media;

public void ClearNegativePixelsCommandExample(RasterImage image, Stream destStream)
{
   RasterCodecs codecs = new RasterCodecs();
   // convert it to TIF
   image.Signed = true;
   codecs.Save(image, destStream, RasterImageFormat.Tif, 24);
   image.Dispose();

   // Load this image as signed
   codecs.Options.Load.Signed = true;

   // Load the source image
   image = codecs.Load(destStream);
   Debug.Assert(image.Signed);

   // Clear the negative pixels and save it it back
   ClearNegativePixelsCommand command = new ClearNegativePixelsCommand();
   command.Run(image);
   Debug.Assert(!image.Signed);

   codecs.Save(image, destStream, RasterImageFormat.Tif, 24);

   // Clean up
   image.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.Windows.Media

Public Sub ClearNegativePixelsCommandExample(ByVal image As RasterImage, ByVal destStream As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' convert it to TIF
   image.Signed = True
   codecs.Save(image, destStream, RasterImageFormat.Tif, 24)
   image.Dispose()

   ' Load this image as signed
   codecs.Options.Load.Signed = True

   ' Load the source image
   image = codecs.Load(destStream)
   Debug.Assert(image.Signed)

   ' Clear the negative pixels and save it it back
   Dim command As ClearNegativePixelsCommand = New ClearNegativePixelsCommand()
   command.Run(image)
   Debug.Assert((Not image.Signed))

   codecs.Save(image, destStream, RasterImageFormat.Tif, 24)

   ' Clean up
   image.Dispose()
End Sub
必要条件

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

参照

参照

ClearNegativePixelsCommandメンバ
Leadtools.ImageProcessing名前空間