有幾千張像下面這樣的影像,掃描的邊緣很復雜(首先是一個完全規則的白色,然后是一個非常模糊的灰色/黑色),是否有一種很好的演算法來計算區域的坐標? -保持?在下面的例子中,從西北角順時針方向,最佳坐標是:
- 121,18
- 1934,18
- 1934,1312
- 121,1312
所以從這個輸入影像...

... 可以裁剪以去除任何染成紅色的東西,如下所示:

To clarify, I do know how to use ImageMagick or other tools to crop to that area. What I'm not sure about is how to figure out how to get to those above numbers? Do you just binarize the image and then go left to right until you hit "white" for the first time, then do the same from top to bottom, right to left and bottom to top? Or is there some library, script, etc. which already does that for you?
uj5u.com熱心網友回復:
我會使用影像的垂直和水平投影。通過對最高過渡的簡單檢測,您可以輕松找到背景和紙張之間的界限。

uj5u.com熱心網友回復:
您的影像在黑色邊框周圍有白色邊框。因此,您可以在填充適當的顏色后執行兩個模糊修剪程序,以確保它遍布整個影像。所以在 ImageMagick 6 中,它將是
輸入:

convert book.jpg -bordercolor white -border 1 -fuzz 55% -trim repage -bordercolor black -border 1 -trim repage book_trimmed.jpg
結果:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/360525.html
