how to convert 1 channel grayscale image into 3 channel?

7 vues (au cours des 30 derniers jours)
Saira charan
Saira charan le 30 Juil 2018
Modifié(e) : Adam le 31 Juil 2018
I have to train my images through vgg16, for which i need to convert my 1 channel grayscale images to 3 channel. i have used rgbimage=I(:,:,[1 1 1]) also repmat, but when i apply this command it changes my image into binary. I just need to change number of channels by keeping it grayscale. Help please!
  1 commentaire
Adam
Adam le 30 Juil 2018
Modifié(e) : Adam le 30 Juil 2018
cat( 3, I, I, I )
should work, though looks ugly. Repmat, done correctly, should work too I would have thought. I imagine there is an Image Processing Toolbox function that does it though I can't remember off hand.

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 30 Juil 2018
These are equivalent and working:
RGB = repmat(I, [1, 1, 3])
RGB = I(:, :, [1, 1, 1])
RGB = repelem(I, [1, 1, 3])
They do not change the class of the image or the values. Your impression, that this changes your "image to binary" is not correct. Either the observation is not correct or another command is responsible for the effect. Please post the relevant part of the code and mention, why you assume, that the image is changed.
  2 commentaires
Saira charan
Saira charan le 30 Juil 2018
I=imread('mdb120.png'); RGB = repmat(I, [1, 1, 3]) imwrite(I.*uint8(I),'mdb120.png')
Can you suggest what is wrong in this? My images are grayscale 1 channel. And using these commands does change it into 3 channel but the images are converted to binary. As i am dealing with mammograms i cannot get results from images that are just black n white. I hope i am clear now.
Adam
Adam le 31 Juil 2018
Modifié(e) : Adam le 31 Juil 2018
What is the range of I.*uint8(I)? If you plot I and plot that you should see if one or other is wrong before just saving them to file.

Connectez-vous pour commenter.

Produits


Version

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by