代码插入:
在代码中加入下面一行,在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