Change image's color/style into the color/style from another image

Viewed 61

For example, there are four images like below:

enter image description here enter image description here enter image description here enter image description here

How to change the colors of the objects in these four images into the grey one from the image below (please ignore the three axes in the middle)? In other words, after changing, the colors of the four images above should look like the one below.

If this is difficult, it is not necessary to follow the image below. As long as the four images above are uniformed with the same color (e.g., grey), it is also OK. Is there any way to do this? Thank you! enter image description here

Update: I used cv2 to get the contours and used cv2.fillPoly to fill gray color. It is almost there but after filling the contour lines disappeared as below. Can the lines be kept after filling gray color? Thank you!

import cv2  
img = cv2.imread("image.jpg")  
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)  
ret, binary = cv2.threshold(gray,127,255,cv2.THRESH_BINARY)  
 
contours, hierarchy = cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)   
cv2.fillPoly(img,[contours[1]],(128,128,128))
plt.imshow(img)
plt.show()

enter image description here

0 Answers
Related