operations.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Smart-Surveillance-System-using-Raspberry-Pi 作者: OmkarPathak 项目源码 文件源码
def resize(images, size=(100, 100)):
    """ Function to resize the number of pixels in an image.

    To achieve a standarized pixel number accros different images, it is
    desirable to make every picture of the same pixel size. By using an OpenCV
    method we increase or reduce the number of pixels accordingly.
    """
    images_norm = []
    for image in images:
        is_color = len(image.shape) == 3
        if is_color:
            image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        # using different OpenCV method if enlarging or shrinking
        if image.shape < size:
            image_norm = cv2.resize(image, size, interpolation=cv2.INTER_AREA)
        else:
            image_norm = cv2.resize(image, size, interpolation=cv2.INTER_CUBIC)
        images_norm.append(image_norm)

    return images_norm
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号