简体   繁体   English

图像处理中从彩色到灰度的变化

[英]change from colored to grayscale in image processing

today I treid a python filtering code that supposes to increase the noise in the image(de-noising) for a gray-scale image(medical image) and it's for a skull, the problem is i keep getting colored pixels, i mean the noise increased in terms of colored image, not in grayscale so please help me to make the code filter in gray-scale mode, extra details:今天我尝试了一个 python 过滤代码,它假设增加图像中的噪声(去噪)用于灰度图像(医学图像),它是用于头骨,问题是我不断得到彩色像素,我的意思是噪声增加了彩色图像,而不是灰度,所以请帮我在灰度模式下制作代码过滤器,额外的细节:

the code:编码:

enter link description to see the filter code输入链接描述以查看过滤器代码

original image:原图:

the de-noised image after applying noise filter:应用噪声滤波器后的去噪图像:

you can see the problem clearly that when i zoom into the picture i can see the colored pixels, while it supposes to be a gray-scale form您可以清楚地看到问题,当我放大图片时,我可以看到彩色像素,而它应该是灰度形式

colored pixels in the filtered image:过滤图像中的彩色像素:

partial zoom in局部放大

full zoom in全放大

so please guess does anybody knows how to edit that code so that it can increase the noise in form of grayscale mode.所以请猜测是否有人知道如何编辑该代码,以便它可以以灰度模式的形式增加噪声。

Your input image is a 3-channel JPEG.您的输入图像是 3 通道 JPEG。 Make it greyscale (1 channel) before applying noise then it won't be able to treat the channels differently because there will only be one.在应用噪声之前将其设为灰度(1 个通道),那么它将无法对通道进行不同的处理,因为只有一个通道。

img.transform_colorspace('gray')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM