如何将图像转换为 Redscale?
我正在 OpenCV 中处理图像像素的光和颜色。我遇到了红标效应。如何在OpenCV中实现呢?我尝试了几种方法来操纵像素 RGB 值。但我有一种感觉,我可能需要使用 HSV 颜色空间...请帮助。
I was playing with the light and color of pixels of an image in OpenCV. I came across the redscale effect. How to implement it in OpenCV? i have tried several ways to manipulating the pixel RGB values. But i have a feeling that i might need to use HSV color space... pls help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我设法创建了 Javascript,它将图像转换为类似于 redscale 效果 的模式。
编辑:
我简化了红标效果并使其更接近“真实”效果。
JsFiddle 演示
I managed to create Javascript which converts image into mode similar to redscale effect.
EDIT:
I simplified redscale effect and made it closer to the 'real' one.
JsFiddle Demo
在处理中它是如此简单。
in Processing it's so easy.
我会这样做(逐个像素):
255 - 灰度
作为不透明度)伪代码:
注意:包括alpha在内的所有输入都被认为在0到255之间,因此outputAlpha也将如此。
如果您使用 0 到 1 之间的 alpha,则需要调整代码。
I would do it like this (pixel by pixel):
255 - grayscale
as opacity)Pseudocode:
Note: all inputs including alpha are considered between 0 and 255 and so outputAlpha will be too.
You'll need to adapt the code if you work with alpha between 0 and 1.
在 0x69 的注释上希望得到答案的认可。我很想说他实际上没有回答这个问题,这个问题指的是 OpenCV。
我知道这个问题很“老”,但我发现我可能会对这个话题有所启发。
我的答案包含的是如何隔离通道并将它们相互减去的方法。
我和我的项目组正在进行一个涉及 c++ 和 OpenCV 2.3 的项目
(版本非常重要,因为 OpenCV 2.1 是用普通 c 编码的。但是算法没有不同)
所做的:
我们需要做的是隔离绿色,然后减去红色和蓝色通道,这就是我们 我认为你可以使用它的这些部分
这里的重要部分是 mixChannels 函数,
阅读更多内容
http://opencv.itseez.com/modules/ core/doc/operations_on_arrays.html?highlight=mixchannels#mixchannels
花了一些时间来理解。结果将给出代表各个通道的一幅或多幅灰度图像。 (如果您希望能够看到它是红色的,您始终可以进行类似的转换以获得您想要的通道,将其混合到 RGB 图片中的单个通道。这都是关于强度的,嗯 :3 )
On the note of 0x69 wanted credit for the answer. I'd very much say that he did in fact not answer the question, which refers to OpenCV.
I know that the question is 'old', but I found I might shed some light on the topic.
That which my answer contains, is the approach on how to isolate channels, and subtract these from each other.
My project group and I are in the midst of a project involving c++ and OpenCV 2.3
(version is very important, since OpenCV 2.1 is coded in normal c. The algorithm however does not differ)
What we needed to do was isolate green, and then subtract the red and blue channels, this was how we did it:
That which I was thinking you could use was these parts of it
The essential part here is the mixChannels function,
read more on
http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=mixchannels#mixchannels
It took some time to understand. And the result will give one or more grayscale images representing individual channels. (You can always do a similar conversion to have the channel you want, mixed to a single channel in an RGB picture, if you want to be able to see that it is red. It's all about intensities, eh :3 )
我以一种非常简单的方式将此代码转换为 opencv。由于opencv将颜色视为bgr而不是rgb,所以我做了一些更改。代码工作正常...如果有任何错误,请编辑。
I have converted this code to opencv in a very simple way. since opencv considers the color as bgr and not rgb, i made some changes. the code works fine ...please edit if there is any mistake.