07. Copy and Paste
07. Copy and Paste
Copy and Paste
Prerequisites
1
python
1. Copy and Paste
Literally, copy and paste we use on vision engineering. Sometimes we wanna reduce the region of interest, manage the set of images and so on.
Bascially, source image and target image should be same format about byte type and channels. If it is not same, it will be making Logical error or silent failure(critical)
2. Copy and Paste Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import cv2 as cv
import os
import ImageUtils
import MultiImageViewer as view
if __name__ == "__main__":
img = ImageUtils.readImage(ImageUtils.getDataPathWithFile("cat.png"))
img_gray = ImageUtils.convertColorSpace(img, cv.COLOR_BGR2GRAY)
img[100:200, 100:200] = img_gray[100:200, 100:200] # Not Working and error
img_copy = img.copy()
img_copy[100:200, 100:200] = img[300:400, 300:400]
viewer = view.MultiImageViewer.from_images(img, img_copy, sync_view=False)
viewer.run()
img_ref = img
img_ref[100:200, 100:200] = img[300:400, 300:400]
viewer = view.MultiImageViewer.from_images(img, img_ref, sync_view=False)
viewer.run()
image + deepcopy (.copy())
image + shallowcopy (=)
This post is licensed under CC BY 4.0 by the author.

