[英]Resize ROI in an image by mantaining original image size
我将roi大小调整为一半,然后附加到图像上,有关更多信息,请参见代码:
import numpy as np
import cv2
image = cv2.imread("1.png")
print(image.shape)
h = image.shape[0]
w = image.shape[1]
center_x = int(w/2)
center_y = int(h/2)
#get the roi, suppose the roi is in the center of the image
roi = image[center_y-50:center_y+50,center_x-140:center_x+140,:].copy()
roi_h = roi.shape[0]
roi_w = roi.shape[1]
resize_roi = cv2.resize(roi,(int(roi_w/2),int(roi_h/2)))
print(resize_roi.shape)
#delete the old roi
image[center_y-50:center_y+50,center_x-140:center_x+140,:] = 255
#append the resize_roi
image[center_y-int(50/2):center_y+int(50/2),center_x-int(140/2):center_x+int(140/2),:] = resize_roi
cv2.imshow("Image", image)
cv2.imshow("roi", roi)
cv2.imshow("resize_roi", resize_roi)
cv2.waitKey(0)
投资回报率
调整投资回报率
具有尺寸roi的图像
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.