白紙かどうか判断するには、Leadtools.ImageProcessing.Core名前空間のBlankPageDetectorCommandクラスで可能です。また、マルチページファイルから1ページだけ除去するにはRasterImage.RemovePageAtメソッドを使用します。
※BlankPageDetectorCommandクラスはDocument Imaging以上で使用できます。
サンプルコード(VB.NET)
Dim codecs As New RasterCodecs
Dim tempimage As RasterImage
tempimage = codecs.Load("multipage.tif", 0, CodecsLoadByteOrder.Bgr, 1, -1)
Dim defaultpagecount As Integer = tempimage.PageCount
For i As Integer = 1 To defaultpagecount
If i = tempimage.PageCount Then
Exit For
End If
tempimage.Page = i
' 画像が空白ページかどうかを確認します。
Dim command As BlankPageDetectorCommand = New BlankPageDetectorCommand
command.Flags = BlankPageDetectorCommandFlags.DetectNoisyPage
command.Run(tempimage)
' 空白ページを削除します。
If command.IsBlank = True Then
tempimage.RemovePageAt(i)
End If
Next
サンプルコード(C#)
RasterCodecs codecs = new RasterCodecs();
RasterImage tempimage = default(RasterImage);
tempimage = codecs.Load("multipage.tif", 0, CodecsLoadByteOrder.Bgr, 1, -1);
int defaultpagecount = tempimage.PageCount;
for (int i = 1; i <= defaultpagecount; i++) {
if (i == tempimage.PageCount) {
break;
}
tempimage.Page = i;
// 画像が空白ページかどうかを確認します。
BlankPageDetectorCommand command = new BlankPageDetectorCommand();
command.Flags = BlankPageDetectorCommandFlags.DetectNoisyPage;
command.Run(tempimage);
// 空白ページを削除します。
if (command.IsBlank == true) {
tempimage.RemovePageAt(i);
}
}
関連情報
0 コメント