I have a dataset of medical images in grayscale Png format which must be converted to RGB format. Tried many solutions but in vain.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you want to just convert the format, the following method will help you:
In python3, using PILLOW and 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:
- Using CNNs and considering the colorization as a regression problem: Let there be Color!
- Using CNNs and considering the colorization as a classification problem: Colorful Image Colorization
- Using GANs : cycle-gan
回答2:
GIMP, Menu image -> Mode -> RGB mode