4
Q
字符圖像變薄
A
回答
3
相同尺寸的第一點:找到適合文本旋轉的角度,並通過角度旋轉圖像。在您的示例中,您可以通過查找邊緣上的大黑色補丁和白色區域之間的線條角度來做到這一點。看看edge detection和hough transform,以幫助您找到線條,然後幫助您找到他們的角度。 OpenCV對這兩種算法都有很好的實現。
對於你的第二點:這是形態操作binary skeleton在行動。
0
您可以使用下面的代碼來檢測和糾正歪斜,但我需要你的幫助,如果你得到任何細化算法... asume輸入圖像的圖片框....
try
{
//Check if there exists an image on the picture box
if (pictureBox1.Image == null)
{
MessageBox.Show("Please load an image first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
uploadImageToolStripMenuItem.PerformClick();
return;
}
Bitmap image = new Bitmap(pictureBox1.Image);
BitmapData imageData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
//document image skew detection starts here
DocumentSkewChecker skewChecker = new DocumentSkewChecker();
// get documents skew angle
double angle = skewChecker.GetSkewAngle(imageData);
// create rotation filter and rotate image applying the filter
RotateBilinear rotationFilter = new RotateBilinear(-angle);
rotationFilter.FillColor = Color.White;
image.UnlockBits(imageData);
//if the angle is more 90 or 180, consider it as a normal image or if it is not, perform a skew correction
if (-angle == 90 || -angle == 180)
{
pictureBox1.Image = image;
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
return;
}
//Bitmap rotatedImage = rotationFilter.Apply();
//draw a bitmap based on the skew angle...
Bitmap returnBitmap = new Bitmap(image.Width, image.Height);
Graphics g = Graphics.FromImage(returnBitmap);
g.TranslateTransform((float)image.Width/2, (float)image.Height/2);
g.RotateTransform(((float)angle));
g.TranslateTransform(-(float)image.Width/2, -(float)image.Height/2);
g.DrawImage(image, new Point(0, 0));
pictureBox1.Image = returnBitmap;
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
相關問題
- 1. 變薄
- 2. 內部變薄
- 3. 在OCR中爲圖像製作更薄的文字
- 4. Python圖像字符
- 5. 字符串圖像
- 6. Qt橢圓邊框變薄
- 7. 矢量形狀變薄
- 8. WPF圖像的字符串和字符串圖像
- 9. Rails圖像字符串圖像文件
- 10. 將圖像分解爲字符圖像
- 11. 爲什麼`tkinter.ttk.Notebook`選項卡變得更薄更薄?
- 12. Codeigniter像字符與變音符號?
- 13. CSS非常薄的字體?
- 14. 字符串[]圖像失敗
- 15. 圖像base64字符串
- 16. SWT圖像/從字符串
- 17. 字符串圖像在PHP
- 18. 在圖像上寫字符
- 19. 將圖像標記中的圖像src轉換爲字符串變量
- 20. scikit圖像保存圖像字節字符串
- 21. 薄WHITELINE是被添加時調整圖像大小
- 22. base64字符串到字節到圖像
- 23. 字符串網址圖像到位圖
- 24. 如何在JSP中分配圖像src =字符串變量?
- 25. 改變所有的圖像在一個字符串
- 26. 我如何將圖像名稱分配給字符串變量
- 27. 「_」字符和文件名可變衝突,保存圖像
- 28. 移動圖像... javascript聲明變量爲字符串
- 29. JavaScript使用字符串變量作爲URL插入圖像
- 30. 如何連接變量和字符串以顯示圖像?