public static void Run()
{
// ExStart:BinarizationWithOtsuThreshold
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();
// Load an image in an instance of Image
using (Image image = Image.Load(dataDir + "aspose-logo.jpg"))
{
// Cast the image to RasterCachedImage and Check if image is cached
RasterCachedImage rasterCachedImage = (RasterCachedImage)image;
if (!rasterCachedImage.IsCached)
{
// Cache image if not already cached
rasterCachedImage.CacheData();
}
// Binarize image with Otsu Thresholding and Save the resultant image
rasterCachedImage.BinarizeOtsu();
rasterCachedImage.Save(dataDir + "BinarizationWithOtsuThreshold_out.jpg");
}
// ExEnd:BinarizationWithOtsuThreshold
}
}