c语言中基于条件的OpenCV-Mat掩模#

2024-04-25 05:14:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在OpenCvSharp中实现MaxRGB过滤器。我发现了类似的solution in Python,但是我不知道如何在OpenCVAcLISH或C++中写^ { CD1}}。这意味着将通道中的值设置为0,其中值小于掩码中的值。在

def max_rgb_filter(image):
# split the image into its BGR components
(B, G, R) = cv2.split(image)

# find the maximum pixel intensity values for each
# (x, y)-coordinate,, then set all pixel values less
# than M to zero
M = np.maximum(np.maximum(R, G), B)
R[R < M] = 0
G[G < M] = 0
B[B < M] = 0

# merge the channels back together and return the image
return cv2.merge([B, G, R])
< > {{CD2}}的C/C++选择是什么?还是必须使用常规循环?在


Tags: theinimage过滤器returnnpmergecv2