Expose Threshold Control For Tiff Binarization

In this tutorial, we will explore the C# source code provided for the “TIFF Binarization Threshold Control Exposure” feature with Aspose.Words for .NET. This feature allows you to control the binarization threshold when converting a document to TIFF format.

Step 1: Setting up the environment

Before you begin, make sure you’ve set up your development environment with Aspose.Words for .NET. Make sure you’ve added the necessary references and imported the appropriate namespaces.

Step 2: Loading the document

// Path to your documents directory
string dataDir = "YOUR DOCUMENTS DIRECTORY";

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

In this step, we load the document using the Document method and passing the path to the DOCX file to load.

Step 3: Configure image backup options

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

In this step, we configure backup options for images. We create a new ImageSaveOptions object specifying the desired save format, here “Tiff” for the TIFF format. We also set compression options, image color mode and TIFF binarization method with specified binarization threshold.

Step 4: Backing up images

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

In this last step, we save the document images in TIFF format using the Save method and passing the path to the output file, along with the specified save options.

Now you can run the source code to convert your document to TIFF format while controlling the binarization threshold with the specified options. The resulting file will be saved in the specified directory with the name “WorkingWithImageSaveOptions.ExposeThresholdControlForTiffBinarization.tiff”.

Sample source code Exposing Threshold Control For Tiff Binarization


// Path to your document directory 
 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);
            
        

Conclusion

In this tutorial, we explored the exposure feature of the TIFF Binarization Threshold Control with Aspose.Words for .NET. We learned how to control the binarization threshold when converting a document to TIFF format.

This feature is useful when you want to adjust the binarization threshold to get TIFF images with better quality and clarity. By specifying the binarization threshold with save options, you can get custom results tailored to your needs.

Aspose.Words for .NET offers a wide variety of advanced features for document manipulation and generation. Exposing the TIFF Binarization Threshold Control is one of the many powerful tools it puts at your disposal.

Feel free to incorporate this feature into your Aspose.Words for .NET projects to achieve high quality TIFF images with precise binarization threshold control.