Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将图像复制到特定位置的另一个图像_Python_Image Processing_Opencv3.0 - Fatal编程技术网

Python 将图像复制到特定位置的另一个图像

Python 将图像复制到特定位置的另一个图像,python,image-processing,opencv3.0,Python,Image Processing,Opencv3.0,我试图将图像的某个区域复制到同一图像的另一个位置。我试着用StackOverflow上的代码。我将给出我尝试过的代码片段: roi = frame[ry1:ry2, rx1:rx2] roi.shape frame = frame.copy() frame[:roi.shape[0], :roi.shape[1]] = roi 您可以使用此示例: import cv2 def roi(frame, x1, y1, w, h, x2, y2): # x1

我试图将图像的某个区域复制到同一图像的另一个位置。我试着用StackOverflow上的代码。我将给出我尝试过的代码片段:

    roi = frame[ry1:ry2, rx1:rx2]
    roi.shape
    frame = frame.copy()
    frame[:roi.shape[0], :roi.shape[1]] = roi

您可以使用此示例:

import cv2

def roi(frame, x1, y1, w, h, x2, y2):
    # x1, y1: from
    # w, h: size
    # x2, y2: to
    roi = frame[y1:y1+h, x1:x1+w]
    frame = frame.copy()
    frame[y2:y2+h, x2:x2+w] = roi
    return frame


image = cv2.imread('test.png')
image = roi(image, 100, 120, 90, 150, 320, 310)
cv2.imshow("Image", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

你可以使用掩蔽