原創|使用教程|編輯:龔雪|2014-05-29 09:15:08.000|閱讀 1095 次
概述:本文主要介紹如何使用LEADTOOLS的圖像清理功能。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
LEADTOOLS Document Imaging Developer Toolkit的其中一個基本功能就是圖像清理(也稱為預處理)。當紙文檔掃描成數字形式時,總有不完善之處。掃描文件中可能包含一個角、打孔機留下的黑點,折疊后的線條以及灰塵等斑點,對OCR、條形碼和壓縮算法等不利。
大部分文檔影像庫都要求文檔圖像必須是黑色和白色。然而LEADTOOLS打破了該限制。LEADTOOLS的文檔清理函數會返回它所執行的動作的相關信息。例如,你可以獲取糾偏角度、矩形裁剪、填補區域,并且你可以在彩色圖像中使用這些操作。
// First make a copy of the image using (RasterImage image = viewer.Image.Clone()) { // If the image is not 1bpp black and white, convert it if (image.BitsPerPixel != 1) { AutoBinarizeCommand autoBin = new AutoBinarizeCommand(); autoBin.Flags = AutoBinarizeCommandFlags.DontUsePreProcessing; autoBin.Run(image); ColorResolutionCommand colorRes = new ColorResolutionCommand(); colorRes.BitsPerPixel = 1; colorRes.Run(image); } // Process the 1bpp copy DeskewCommand deskewCom = new DeskewCommand(); deskewCom.Flags = DeskewCommandFlags.ReturnAngleOnly; deskewCom.Run(image); // Apply the same transformation on the original color image using // the data from the 1bpp cleanup function RotateCommand rotateCom = new RotateCommand(); rotateCom.Flags = RotateCommandFlags.Resample; rotateCom.FillColor = viewer.Image.GetPixelColor(0, 0); rotateCom.Angle = deskewCom.Angle; rotateCom.Run(viewer.Image); }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網