opencv 图片截取圆_OpenCV裁剪图像与椭圆

本文介绍如何利用OpenCV围绕图像中的对象绘制椭圆,并裁剪出仅包含该对象的图像。通过设置椭圆参数并使用cv::ellipse函数绘制,然后结合cv::And操作来获取椭圆内的像素,最终得到只包含目标对象的新图像。
摘要由CSDN通过智能技术生成

I have an image (cv::Mat) with size of 92x112 I want to surround the object in this image with a ellipse then get only this pixels to create another image containing only the object.

I mean, cropping the original image with a ellipse.

It's possible?

I am trying drawing a ellipse, but the ellipse don't draw complete, with that:

ellipse(escalada, Point(92/2,112/2), Size(92/2*0.95,112/2*0.85), 0.0, 90.0, 0.0, Scalar(255,0,0), 3, 8);

and made some test with cvSetImageROI to crop the image, but this method works only with cvRect.

Some idea?

解决方案

I solve using this:

imagen = imread(nombre_imagen,0); //read image (grayscale)

//Use old C interface

IplImage *res,*roi;

IplImage src(imagen);

res = cvCreateImage(Size(imagen.rows,imagen.cols),8,1);

roi = cvCreateImage(Size(im

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值