ROI****区域
在图像处理的领域,我们经常会对图像的某个特定区域进行关注,这个区域被称为感兴趣区域(Region of Interest,ROI)。
ROI的存在有以下几个主要原因:
-
提高效率:通过只处理感兴趣的区域,可以大大减少计算量,从而提高处理速度和效率。
-
降低资源消耗:因为只需要处理和存储感兴趣区域的数据。减少了内存和存储的需求。
-
提高准确性:专注于特定区域,可以减少噪声和干扰,提高处理和分析的准确性。
-
简化操作:在特定区域内进行操作可以简化算法设计和实现,特别是在处理复杂图像时。
绘制直线**-**line()
void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
img :目标图像。
pt1 & pt2 :线段的起点和终点。
color :线条颜色。
thickness :线条宽度。
lineType :线条类型,可选8连接、4连接或反走样线(抗锯齿)。
shift :坐标小数位数控制。
绘制矩形**-rectangle()
void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
void rectangle(Mat& img, Rect rec, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
通用参数:
img (Mat&): 图像对象用于绘制矩形的图像。
color (const Scalar&): 矩形的颜色或亮度**。
thickness (int): 边框粗细。负数,绘制填充的矩形。
lineType (int): 边框线型,确定线条的连接方式和显示效果。
shift (int): 坐标点的小数位数。
特殊参数:
pt1 和 pt2 (Point): 矩形的两个顶点,分别表示矩形的左上角和右下角点坐标。
rec (Rect): Rect 类定义了矩形的区域,包含左上角坐标和矩形的宽高。
绘制多边形**-polylines()
void polylines(Mat& img, const Point** pts, const int* npts, int ncontours, bool isClosed, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
img (Mat&): 图像对象,这是绘制多边形的图像。
pts (const Point): 顶点指针数组,顶点坐标的数组,表示每个轮廓的顶点。
npts (const int): 每条轮廓的顶点数,数组 npts 指定每个轮廓中的顶点数量。
ncontours (int): 轮廓数量,指定要绘制的轮廓数量**。
isClosed (bool): 是否闭合。
color (const Scalar&): 设置多边形的颜色。
thickness (int): 线条厚度,设置多边形线条的厚度,默认值为 1。
lineType (int): 线条类型,设置线条的连接类型,可选值有:
8 或 0 : 8 邻接线,默认值。
4 : 4 邻接线。
CV_AA : 抗锯齿线,用于绘制更平滑的线条。
shift (int): 小数位精度,默认值为 0 。
绘制圆**-circle()
void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
img (Mat&):绘制圆形的图像对象。
center (Point):圆心的坐标,指定圆形的位置。
radius (int):圆的半径,单位是像素**。
color (Scalar):圆形的颜色。
thickness (int,默认值=1):圆形边框的线宽。
**lineType (int,默认值=8)**线条类型,指定圆形边框的线型。
shift (int,默认值=0):用于控制坐标和半径的精度。默认值为 0,表示没有小数位。
绘制椭圆**-ellipse()
void ellipse(Mat& img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
img (Mat&):图像对象,是一个传入的引用,函数会在该图像上绘制椭圆。
center (Point):椭圆的中心点坐标,确定椭圆的中心位置。
axes (Size):椭圆的长轴和短轴的尺寸**。
angle (double):椭圆的旋转角度,以逆时针方向为正,单位是度。
startAngle (double):椭圆弧的起始角度,单位为度。
endAngle (double):椭圆弧的结束角度,单位为度。
color (Scalar):椭圆的颜色。
thickness (int,默认值=1):椭圆的边框厚度。如果为正数,则绘制椭圆边框,数值越大边框越粗。
lineType (int,默认值=8):线条类型,指定椭圆边框的线型。
shift (int,默认值=0):控制椭圆坐标精度的参数。
绘制文字**-putText()
void putText(Mat& img, const String& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false)
img (Mat&):图像对象,函数会在此图像上绘制文本。
text (String):要绘制的文本内容。
org (Point):文本的起始位置,即文本左下角**的坐标。
fontFace (int):字体类型。
fontScale (double):字体的缩放因子,用来控制字体的大小。
color (Scalar):文本的颜色。
thickness (int,默认值=1):文本的粗细。
lineType (int,默认值=8):文本的线型。
bottomLeftOrigin (bool,默认值=false):是否使用左下角作为文本的基准点。