0

I have a dataset of medical images in grayscale Png format which must be converted to RGB format. Tried many solutions but in vain.

sneka
  • 21
  • 2
  • _"Tried many solutions but in vain"_. Ok, post a couple and we'll start from there. – Kevin Jan 14 '19 at 13:43
  • 1
    What is the point? You would be tripling the storage requirements without adding any information or value. Why do you think you need to convert them? – gavinb Jan 14 '19 at 13:50
  • This is very unlikely to be a programming problem. There are any number of off-the-shelf image processing applications (whether UI based or CLI, like `netpbm`) that can perform this function. – Alnitak Jan 14 '19 at 13:56
  • I'm voting to close this question as off-topic because it's not a programming problem. – Alnitak Jan 14 '19 at 13:57

2 Answers2

1

GIMP, Menu image -> Mode -> RGB mode

Jingshao Chen
  • 3,405
  • 2
  • 26
  • 34
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:

schlodinger
  • 537
  • 3
  • 14