gpt4 book ai didi

c++ - 从图像中裁剪椭圆形而不是在 OpenCV 中绘制椭圆形

转载 作者:行者123 更新时间:2023-11-28 03:01:45 25 4
gpt4 key购买 nike

我有一个矩形,我想从给定的图像中提取它的椭圆形式。我的代码如下所示:

RotatedRect ellipse ;
float p1 = (float) rect.width/2 + rect.x;
float p2 = (float) rect.height/2 + rect.y;
CvPoint2D32f p = cvPoint2D32f(p1,p2);
ellipse.center = p;
ellipse.angle = 0;
ellipse.size = cvSize2D32f((float)rect.width, (float)rect.height);
ellipse( image_colored, minEllipse, CV_RGB(255,255,255), 2, 8 );

这段代码的输入是:一张图片(image_colored)和CvRect(rect)。最后一行代码在“image_colored”内绘制了一个白色椭圆,但我希望在其他图像中裁剪生成的椭圆,或者只是将图像的其余部分涂成黑色。

任何帮助,将不胜感激。谢谢。

PS:我无法使用此 link 中建议的函数 cvEllipse(...) .因为 cvEllipse 不接受 CvPoint2D32f 类型的对象,也不接受 CvSize2D32f 类型的对象。

最佳答案

制作一个带有填充椭圆的图像,并将其用作与您的图像组合(按位和)的掩码 OpenCV bitwise_and + maskSegmenting Lungs and nodules in CT images

关于c++ - 从图像中裁剪椭圆形而不是在 OpenCV 中绘制椭圆形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20617307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com