opencv预处理图像

1 改变图像大小
标题看起来了简单,但是改变图像大小却对小目标的检测有利。cv2中CV_INTER_NN、CV_INTER_LINEAR 、CV_INTER_AREA、CV_INTER_CUBIC到底什么条件用什么呢?查看opencv文档
INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
为什么这里的缩放大小采取32的倍数呢,是因为自然场景OCR检测(YOLOv3+CRNN),CRNN论文中采用的就是高度为32的

def resize_image2(w, h):
    resize_w = w
    resize_h = h

    # limit the max side
    if max(resize_h, resize_w) > MAX_LEN:
        ratio = float(MAX_LEN) / resize_h if resize_h > resize_w else float(MAX_LEN) / resize_w
    else:
        ratio = 1.
    resize_h = int(resize_h * ratio)
    resize_w = int(resize_w * ratio)
    resize_h = resize_h if resize_h % 32 == 0 else (resize_h // 32 + 1) * 32
    resize_w = resize_w if resize_w % 32 == 0 else (resize_w // 32 + 1) * 32
    return resize_w, resize_h

2 像素扩张算法
2.1 分水岭算法
图像处理——分水岭算法

你可能感兴趣的:(机器学习,机器学习)