[英]Convert grayscale png to RGB png image
I have a dataset of medical images in grayscale Png format which must be converted to RGB format.我有一个灰度 Png 格式的医学图像数据集,必须将其转换为 RGB 格式。 Tried many solutions but in vain.
尝试了很多解决方案,但徒劳无功。
GIMP,菜单图像 -> 模式 -> RGB 模式
If you want to just convert the format, the following method will help you:如果您只想转换格式,以下方法将帮助您:
In python3, using PILLOW and Numpy:在python3中,使用PILLOW和Numpy:
From PIL import Image
import numpy as np
im = Image.open(path/to/image, 'r').convert('L')
im = np.stack((im,)*3, axis=-1)
im = Image.fromarray(im)
im.save(path/to/save)
But if you want to colorize the image, know that colorization is an well-known image translation problem.但是如果你想对图像进行着色,要知道着色是一个众所周知的图像翻译问题。 Even if multiple approachs exist depending on the domain, I don't know any method that colorize any kind of images.
即使根据域存在多种方法,我也不知道可以为任何类型的图像着色的任何方法。
Some ways of doing so is to train a neural network, but for that, you need to have a dataset of B/W and colored images.这样做的一些方法是训练神经网络,但为此,您需要有黑白和彩色图像的数据集。 Here are some approaches:
以下是一些方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.