曝光 Tiff 二值化的阈值控制

在本教程中,我们将探索 Aspose.Words for .NET 提供的“TIFF 二值化阈值控制曝光”功能的 C# 源代码。此功能允许您在将文档转换为 TIFF 格式时控制二值化阈值。

步骤 1:设置环境

开始之前,请确保您已使用 Aspose.Words for .NET 设置开发环境。请确保您已添加必要的引用并导入适当的命名空间。

步骤 2:加载文档

//文档目录的路径
string dataDir = "YOUR DOCUMENTS DIRECTORY";

Document doc = new Document(dataDir + "Rendering.docx");

在此步骤中,我们使用Document方法并传递要加载的 DOCX 文件的路径。

步骤 3:配置映像备份选项

ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.Tiff)
{
TiffCompression = TiffCompression.Ccitt3,
ImageColorMode = ImageColorMode.Grayscale,
TiffBinarizationMethod = ImageBinarizationMethod.FloydSteinbergDithering,
ThresholdForFloydSteinbergDithering = 254
};

在此步骤中,我们配置图像的备份选项。我们创建一个新的ImageSaveOptions对象指定所需的保存格式,此处的“Tiff”表示 TIFF 格式。我们还设置了压缩选项、图像颜色模式和 TIFF 二值化方法,并指定了二值化阈值。

步骤 4:备份图像

doc.Save(dataDir + "WorkingWithImageSaveOptions.ExposeThresholdControlForTiffBinarization.tiff", saveOptions);

在最后一步中,我们使用Save方法并传递输出文件的路径以及指定的保存选项。

现在,您可以运行源代码,将文档转换为 TIFF 格式,同时使用指定的选项控制二值化阈值。生成的文件将保存在指定的目录中,名称为“WorkingWithImageSaveOptions.ExposeThresholdControlForTiffBinarization.tiff”。

示例源代码公开 Tiff 二值化的阈值控制


//文档目录的路径
 string dataDir = "YOUR DOCUMENT DIRECTORY"; 

Document doc = new Document(dataDir + "Rendering.docx");

ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.Tiff)
{
	TiffCompression = TiffCompression.Ccitt3,
	ImageColorMode = ImageColorMode.Grayscale,
	TiffBinarizationMethod = ImageBinarizationMethod.FloydSteinbergDithering,
	ThresholdForFloydSteinbergDithering = 254
};

doc.Save(dataDir + "WorkingWithImageSaveOptions.ExposeThresholdControlForTiffBinarization.tiff", saveOptions);
            
        

结论

在本教程中,我们探索了 Aspose.Words for .NET 的 TIFF 二值化阈值控制的曝光功能。我们学习了如何在将文档转换为 TIFF 格式时控制二值化阈值。

当您想要调整二值化阈值以获得质量和清晰度更高的 TIFF 图像时,此功能非常有用。通过使用保存选项指定二值化阈值,您可以获得根据您的需求量身定制的结果。

Aspose.Words for .NET 提供了多种用于文档操作和生成的高级功能。TIFF 二值化阈值控制是它为您提供的众多强大工具之一。

请随意将此功能合并到您的 Aspose.Words for .NET 项目中,以实现具有精确二值化阈值控制的高质量 TIFF 图像。