简体   繁体   English

在android中使用边缘检测选择区域后裁剪图像

[英]Crop image after selecting area using edge detection in android

I want to automatically select area of the page to crop later. 我想自动选择要稍后裁剪的页面区域。 I thought edge detection might be useful and used canny edge detection to find edges of the image. 我认为边缘检测可能是有用的,并使用canny边缘检测来查找图像的边缘。 Now I have this image! 现在我有这个形象! but I've no clear idea to select area of the page as a rectangle. 但我不清楚选择页面区域为矩形。 Can anyone suggest a method or implementation for this problem? 任何人都可以建议这个问题的方法或实现? What I really want to do is this selecting the area of the page as follows. 我真正想要做的是选择页面区域如下。 Is there any other method to do this? 有没有其他方法可以做到这一点? I have also seen boundary detection in the book of introduction to digital image processing using matlab. 我还在使用matlab的数字图像处理介绍书中看到了边界检测。 But I'm not familiar with that. 但我对此并不熟悉。 Can I use that for this purpose? 我可以将它用于此目的吗?

I assume that you have "Canny-ed" image. 我假设你有“Canny-ed”形象。 Now you can use Imgproc.findCountours , to find and store edges (you need List<MatOfPoint> for that). 现在您可以使用Imgproc.findCountours来查找和存储边缘(您需要List<MatOfPoint> )。 Before using findContours i would play with Imgproc.dilate , which might help finding contours(it "fattens" lines so we are sure that findContours wont miss your target). 在使用findContours之前,我会使用Imgproc.dilate ,这可能有助于找到轮廓(它“变胖”线,所以我们确信findContours不会错过你的目标)。 Then you need only to use Imgproc.boudningRect to get your ROI. 然后,您只需使用Imgproc.boudningRect即可获得投资回报率。 Then just crop image using this ROI. 然后使用此ROI裁剪图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM