即使有不同的蓝色调,我怎样才能将蓝色的水转换成另一种?

时间:2018-05-05 06:39:27

标签: python image

enter image description here

如何将图像中水的蓝色转换为白色,尤其是在有不同深浅的蓝色时。然后分离任何其他颜色,并给它例如黑色。一个例子是海洋中的这种污染,你想要检测污染区域,并给它一个明显区别于水的颜色:

enter image description here

2 个答案:

答案 0 :(得分:0)

import cv2
import numpy as np
from matplotlib import pyplot as plt
BLUE = [255,0,0]
img1 = cv2.imread('11.jpg')
replicate = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_REPLICATE)     
reflect = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_REFLECT)
reflect101 = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_REFLECT_101)
wrap = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_WRAP)
constant= 
cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_CONSTANT,value=BLUE)
plt.subplot(231),plt.imshow(img1,'gray'),plt.title('ORIGINAL')
plt.subplot(232),plt.imshow(replicate,'gray'),plt.title('REPLICATE')
plt.subplot(233),plt.imshow(reflect,'gray'),plt.title('REFLECT')
plt.subplot(234),plt.imshow(reflect101,'gray'),plt.title('REFLECT_101')
plt.subplot(235),plt.imshow(wrap,'gray'),plt.title('WRAP')
plt.subplot(236),plt.imshow(constant,'gray'),plt.title('CONSTANT')
plt.show()
cv2.waitKey()
cv2.destroyAllWindows()

答案 1 :(得分:0)

getline(cin, product, ',')