自由格式图像选择(最好在c ++中) [英] free form image selection (preferably in c++)

查看:136
本文介绍了自由格式图像选择(最好在c ++中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的图像操纵。我们注意到您可以指定



在遮罩图片上绘制非零区域,以表示所选部分图像。


I am new to image manipulation. I have noticed that you can specify a rectangular region of interest and others like circles etc in image manipulation libraries like opencv. Basic paint programs like ms-paint incorporate free form selection but i cannot seem to find a function or tutorial on how to do free form image selection in opencv or other image processing libraries. Any ideas on how to achieve this? PS: My preferred language is c/c++.

解决方案

One thing you can try:

If the selection can be represented as a sequence of 2d-vectors, you can think of it as a polygon. Allocate a new 1-channel image that will be your mask and fill it with 0. Then use

void cvFillPoly(CvArr* img, CvPoint** pts, int* npts, int contours, CvScalar color, int lineType=8, int shift=0)

documented on

http://opencv.willowgarage.com/documentation/drawing_functions.html

to draw a non-zero region on the mask image to represent the selected part of the image.

这篇关于自由格式图像选择(最好在c ++中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆