[英]Is there a way to have both grayscale and rgb pixels on the same image opencv C++?
I need to be able to work with images where some regions are grayscale while others are kept on the RGB format. 我需要能够处理某些区域为灰度而其他区域保持为RGB格式的图像。 I don't want to convert an image into a grayscale since it will lose the channels and will become simply one channeled, is there a way to keep the RGB channels of some pixels on the picture and turn the others into a grayscale?
我不想将图像转换为灰度图像,因为它会丢失通道并仅变成一个通道,有没有办法保持图像上某些像素的RGB通道并将其他像素变为灰度?
NO. 没有。
I see two solutions to this: 我看到两种解决方案:
Mat1b
) and a rgb ( Mat3b
) image, and work on the image you need. Mat1b
)和rgb( Mat3b
)图像,然后处理所需的图像。 Mat3b
) image, and set r,g,b channels to the same gray value where you need. Mat3b
)图像,并在需要的地方将r,g,b通道设置为相同的灰度值。 In this way you can mimic to have a mixed gray/rgb image.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.