Convert grayscale png to RGB png image

↘锁芯ラ 提交于 2019-12-14 00:00:04

问题


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



来源:https://stackoverflow.com/questions/54182675/convert-grayscale-png-to-rgb-png-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!