Extract the contour of two images
I tried the following code:
import cv2
import numpy as np
img1 = cv2.imread("IMG_B_TestCube&1&00.png")
img2 = cv2.imread("IMG_TestCube.png")
h1, w1 = img1.shape[:2]
h2, w2 = img2.shape[:2]
# translation matrix of img2
MT = np.float32([[1,0,190],[0,1,-100]])
dst = cv2.warpAffine(img2,MT,(w2,h2))
#create empty matrix
vis = np.zeros((max(h1, h2), w1+w2,3), np.uint8)
#combine 2 images
vis[:h1, :w1, :3] = img1+dst
#vis[:h2, w1:w1+w2, :3] = img2
cv2.imshow('res',vis)
cv2.waitKey(0)
cv2.destroyAllWindows()
The result which I have got is the below:
My new goal is to extract the yellow line of intersection as below:
I checked a lot of examples without finding an optimal solution.
Could you please help in this matter?
Blending these two images will give you only two overlapped squares, no yellow region.
I don't know how you obtained the third image...
BTW, to extract a region of a specific color, use the inRange function...
I repeat my previous question: how did you get the second image with the yellow line? If you don't explain it, we won't be able to help you...
I have got the yellow line by using Photoshop.
I still don't understand... If you want to draw lines, use Paint, not OpenCV...
I don't want to draw the line using Paint. The yellow line in fact is the line of intersection of the green and white image. It is extracted just from the green image. Could it be done using opencv?
i seriously don't understand this question. the 1st image shows the (2d image) intersection of 3d boxes. why do you want ro use a 2d screenshot, to determine the intersection ?
@Abdu. By lookinng @ first image. Do you want to remove dark green rectangle and leave white image alone from first image?
@berak. He probablies wanted to cropped out dark green not light green and not to cropped out piece of white image.