使用opencv增加帧的某些部分的强度

时间:2011-11-24 04:48:40

标签: c image image-processing opencv

假设有一个带有图像的帧。我想只显示像素强度大于120或130的那些部分。我怎么能用OpenCv做到这一点?有没有命令这样做? 然后我需要将这些部分设置为190的强度。

2 个答案:

答案 0 :(得分:1)

您可以尝试cvThreshold功能。对于第二部分,cvFloodFill可能就是您所需要的。

答案 1 :(得分:1)

如astay13所述,您可以使用threshold功能,如下所示:

Mat image = imread("someimage.jpg", 0); // flag == 0 means read as grayscale
Mat mask;

// this tells you where locations >= 120 pixel intensity are
threshold(image, mask, 120.0, 255.0, THRESH_BINARY); 

// this sets those locations to 190 based on the mask you just created
image.setTo(Scalar(190, 0, 0), mask);
imshow("image", image);

希望有帮助!