ios - 修复 Leptonica 1.68 中的局部偏斜

标签 ios iphone c image-processing

我有一个关于 Leptonica 的有趣问题,我想知道其他 SO 成员是否已经看到了。

我正在进行去歪斜操作,并且存在严重的伪影问题,以至于没有人会正确地接受结果,这会降低图像质量而不是它们带来的好处。

这里是产生去歪斜操作的相关代码:

    // Make a black and white version for deskew calculations
    l_int32 thresh;
    PIX * deskewbw = pixMaskedThreshOnBackgroundNorm(pix,NULL,10,15,25,10,2,2,0.1,&thresh);  
    NSLog(@"Used threshold of %d to normalize image for deskew",thresh);

    // Find the local skew
    PTA * ptas, *ptad;
    pixGetLocalSkewTransform(deskewbw, 0, 0, 0, 0.0, 0.0, 0.0, &ptas, &ptad);

    // Cleanup the first B/W version
    pixDestroy(&deskewbw);
    
    // Deskew the original image
    PIX * deskewgray = pixProjectivePtaGray(pix, ptad, ptas, 128);

    // Reduce the deskewed original image to B/W
    pixbw = pixMaskedThreshOnBackgroundNorm(deskewgray, NULL, 10, 15, 25, 10, 2, 2, 0.1, &thresh);

无论我使用这个,还是 pixDeskewLocal 函数(做类似的事情),我都会得到一些非常丑陋的结果,带有交错线效果:

Ugly deskew artifacts

只是为了比较,这里是原始(稍微倾斜)的图像:

Original Image

无论原件是黑色还是白色前景,都会发生这种情况,并且在偏移较多的区域更为严重。在这一点上,我很想让 iOS 为我进行渲染,以避免针对此特定操作使用 Leptonica,但这会增加我工作流程中的转换次数,我宁愿尽可能避免。

有没有其他人遇到/克服过这个问题?关于为什么会发生这种情况/如何解决它的任何指示?

最佳答案

您可以使用函数 pixEndianByteSwap(pixbw); 来解决这个问题。

关于ios - 修复 Leptonica 1.68 中的局部偏斜,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8167784/

相关文章:

ios - 如何从braintree payments中获取卡号?

iphone - 如何通过单击 "Paid"应用程序中的按钮在iPhone的AppStore中打开 "Lite"应用程序页面?

c - 溢出 scanf ("%8s",字符串)?

ios - 在 iOS 上混合视频流

iOS:何时在构建配置中使用哪个代码签名标识?

iphone - 在 For 循环 iphone 中触发另一个线程

sql - C:遍历 SQLite 记录并将每个值分配给变量

c - 关于运算符的指针和值

ios - Xcode 7.0 beta 4 未检测到 swift 2.0

iphone - Cocoa touch——获取设备信息