tesseract源码Page Layout解读1( 二值化,otsu)

代码插入:

在代码中加入下面一行,在tesseract/win64/bin/Realease/可以得到二值化后的图像(tessinput.tif)

api.SetVariable("tessedit_write_images", "true"); 


tessinput.tif(otsu得到的)


代码理解:

TessBaseAPI::ProcessPage[api/tesseractmain.cpp]       ->  
TessBaseAPI::Recognize [api/baseapi.cpp] -> 
/*
//Recognize the tesseract global image and return the result as Tesseractinternal structures.
int TessBaseAPI::Recognize(ETEXT_DESC* monitor) {
    ...
    if (FindLines() != 0)
    return -1;
    ...
    }
*/
TessBaseAPI::FindLines[api/baseapi.cpp] -> 
/** Find lines from the image making the BLOCK_LIST. 
int TessBaseAPI::FindLines() {
    ...
    if (tesseract_->pix_binary() == NULL && //
      !Threshold(tesseract_->mutable_pix_binary())) {//进入二值化
    return -1;
//if (tesseract_->tessedit_write_images) 
//pixWrite("pix_binary.tif", tesseract_->pix_binary(), IFF_TIFF_G4);//可以查看二值化的结果
      
	...
    }
//pix_binary_:初始值为输入的图像,保存布局分析和识别的图像
//Image used for input to layout analysis and tesseract recognition.May be modified by the ShiroRekhaSplitter to eliminate the top-line.
//mutable_pix_binary:&pix_binary_(Destroy any existing pix and return a pointer to the pointer.) 
*/
TessBaseAPI::Threshold[api/baseapi.cpp] ->
/**二值化
 * Run the thresholder to make the thresholded image, returned in pix,
 * wh
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值