Tesseract 和 tiff 格式 - spp 不在集合 {1,3} 中
尝试运行此命令时:
tesseract bond111.tif bond111 batch.nochop makebox
我收到下一个错误
Error in pixReadFromTiffStream: spp not in set {1,3}
Error in pixReadStreamTiff: pix not read
Error in pixReadTiff: pix not read
假设 spp not in set
是这里的主要错误,这是什么意思? 起初它遇到了麻烦,因为 bpp 高于 24,所以我使用 Gimp 减少了它,但这并没有解决问题。
While trying to run this command:
tesseract bond111.tif bond111 batch.nochop makebox
I get the next error
Error in pixReadFromTiffStream: spp not in set {1,3}
Error in pixReadStreamTiff: pix not read
Error in pixReadTiff: pix not read
Assuming that spp not in set
is the main error here, what does it mean?
At first it had trouble because the bpp was higher than 24 so I reduced it using Gimp but that did not resolve the issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能意味着您的 TIFF 图像具有 Alpha 通道,因此 Tesseract 使用的底层 Leptonica 库不支持它。如果您使用的是 Imagemagick,请注意
-draw
等操作可能会导致添加 Alpha 通道。如果您在工作流程中使用convert
并希望立即再次删除通道,请在写入之前通过在输出文件名前添加-background White -flatten +matte
来展平图像,例如:Tesseract(好吧,Leptonica)现在接受 PNG 并且对它们不太挑剔,因此无论如何将您的工作流程迁移到 PNG 可能会更容易。
来源:magick-users 邮件列表发布; tesseract-ocr 邮件列表发布
It probably means your TIFF image has an alpha channel and therefore the underlying Leptonica library used by Tesseract doesn't support it. If you're using Imagemagick then be aware that operations such as
-draw
can cause alpha channels to be added. If you're usingconvert
in your workflow and want to remove the channel again immediately, flatten the image before writing by adding-background white -flatten +matte
before the output filename, e.g.:Tesseract (well, Leptonica) accepts PNGs these days and is less picky about them, so it might be easier to migrate your workflow to PNG anyway.
Sources: magick-users mailing list posting; tesseract-ocr mailing list posting
感谢您的帖子 ZakW,您为我指明了正确的方向。
不管怎样,我还需要设置“-深度8”。无论我尝试什么,质量对于 OCR 来说都不够好。
对我有用的是这个解决方案:
这样我就得到了带有德语变音符号的完美文本。
Thanks for your post ZakW, you pointed me to the right direction.
Anyhow i also needed to set '-depth 8'. Quality was not good enough for OCR, whatever I tried.
What worked for me is this solution:
This way I got perfect text with Umlauts in german.
将转换调整为以下行确实对我有帮助。
请注意,其他答案对我不起作用,因为它们使用已弃用的
+matte
标志而不是-alpha Off
。Adjusting the conversion to the following line did help me.
Note that the other answers did not work for me since they use the deprecated
+matte
flag instead of-alpha Off
.您可以尝试使用 libtiff_tools 提供的命令“tiffinfo”来验证 src 图像的 TIFF 格式。存在多种 TIFF 格式,每像素位数 (bpp) 和每像素采样数 (spp) 具有不同的值。
pixReadFromTiffStream 中出现错误:spp 不在集合 {1,3,4} 中
“spp”值 2 对于 TIFF 无效。
我通过从 Gimp 直接保存为 TIFF 格式解决了这个问题,而不是使用 ImageMagick 的“转换”从 .png 转换为 .tif。
另请参阅:TIFF 格式
You can try using the command 'tiffinfo' provided by libtiff_tools to verify the TIFF format of your src image. A number of TIFF formats exist, with different values for Bits-per-pixel (bpp) and Samples-per-pixel (spp).
Error in pixReadFromTiffStream: spp not in set {1,3,4}
An 'spp' value of 2 is invalid for TIFF.
I solved the problem by saving directly to TIFF format from Gimp, instead of converting from .png to .tif using ImageMagick's 'convert'.
See also: TIFF format