我想裁剪我使用霍夫变换检测到的圆圈,我成功检测到圆圈,但我不明白如何裁剪它们。 这是我用于霍夫变换的代码:
for( int i=0;i<circles.cols();i++){
Point center = new Point( Math.round(circles.get(0,i)[0]),
Math.round(circles.get(0, i)[1]));
System.out.println("X============="+i+":"+circles.get(0,i)[0]);
System.out.println("Y============="+i+":"+circles.get(0,i)[1]);
int radius = (int) Math.round(circles.get(0, i)[2]);
//System.out.println("--Rayon--:"+radius);
Imgproc.circle( image, center, radius, new Scalar(0,0,255),3);//radius, color) `
答案 0 :(得分:0)
您可以裁剪如下图像:
Mat initialImage = ...
Rect crop = new Rect(new Point(column,row),new Size(width,height)); // crop area begins at Point(column,row) with Size(width,height)
Mat croppedImage = new Mat(initialImage,crop);