数据增强——图像翻转,BoundingBox翻转

编程入门 行业动态 更新时间:2024-10-14 14:20:27

数据增强——<a href=https://www.elefans.com/category/jswz/34/1771430.html style=图像翻转,BoundingBox翻转"/>

数据增强——图像翻转,BoundingBox翻转

数据增强——图像翻转,BoundingBox翻转

    • 图像翻转很容易,边界框如何翻转呢?
        • 找到一张没有标注的原图,用opecv在原图上把bbox画出来,利用QQ截图的功能,将坐标标出来
        • 再把图片进行翻转得到下图
        • 两张图进行对比
        • 很明显可以观测到

图像翻转很容易,边界框如何翻转呢?

找到一张没有标注的原图,用opecv在原图上把bbox画出来,利用QQ截图的功能,将坐标标出来


代码如下:

import cv2 as cvimg_path = "./test_image/2007_000027.jpg"
img = cv.imread(img_path)
# 画框
cv.rectangle(img, (174, 101), (349, 351), color=(0, 255, 0),thickness=2)
cv.imshow("img", img)
cv.waitKey(0)
cv.destroyAllWindows()
再把图片进行翻转得到下图


代码如下:

import cv2 as cvimg_path = "./test_image/test.png" # qq截图标注后的图片
img = cv.imread(img_path)
# 翻转
flip_img = cv.flip(img, 1)
cv.imshow("flip_img", flip_img)
cv.imwrite("./test_image/flip_img.png", flip_img)
cv.waitKey(0)
cv.destroyAllWindows()
两张图进行对比


很明显可以观测到

新的xmin = 图像的width - 原来的xmax
新的xmax = 图像的width - 原来的xmin
ymin 和 ymax 不变

用代码计算:

# bbox: xmin, ymin, xmax, ymax
new_xmin = width - old_xmax
new_xmax = width - old_xmin
new_ymin = old_ymin
new_xmax = old_ymax

更多推荐

数据增强——图像翻转,BoundingBox翻转

本文发布于:2024-03-07 09:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1717459.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   数据   BoundingBox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!