Grey Scale -> RGB images from augmentedImageSource

조회 수: 9 (최근 30일)
Samir Gouin
Samir Gouin 2020년 11월 5일
댓글: Samir Gouin 2020년 11월 16일
Hi, I would like to convert grey scale images to [227 227 3]. I'm able to adjust the size using "auimds = augmentedImageSource(imageSize, trainingImages); " but I'm having trouble with converting to RGB (for use with Alex Net).
I've tried:
%grayimg=repmat(grayimg, 1, 1, 3);
%auimds = cat(3, auimds, auimds, auimds);
%auimds(:,:,[1 1 1]);
%RGB = auimds(3, auimds, auimds, auimds);
and the grey2rgb() method
Any suggestions?
  댓글 수: 2
Aditya Patil
Aditya Patil 2020년 11월 16일
Can you elaborate on the issue you are facing? Share any errors that were shown, and also share the output of the "version" command.
Samir Gouin
Samir Gouin 2020년 11월 16일
Version '9.8.0.1359463 (R2020a) Update 1'
Error is in the photo

댓글을 달려면 로그인하십시오.

답변 (1개)

Subhadeep Koley
Subhadeep Koley 2020년 11월 16일
You can use the ColorPreprocessing Name-Value pair of augmentedImageSource to achieve what you want.
imageSize = [227 227 3];
auimds = augmentedImageSource(imageSize, trainingImages, 'ColorPreprocessing', 'gray2rgb'); % 'trainingImages' is your image datastore
Also if your using MATLAB R2018a or above, you might want to use augmentedImageDatastore instead of the augmentedImageSource due to the Compatibility Considerations.
augmentedImageDatastore is a direct replacement of augmentedImageSource. Like below,
imageSize = [227 227 3];
auimds = augmentedImageDatastore(imageSize, trainingImages, 'ColorPreprocessing', 'gray2rgb'); % 'trainingImages' is your image datastore
  댓글 수: 1
Samir Gouin
Samir Gouin 2020년 11월 16일
Thanks for your help! I am using version R2020a so I've implemented the second approach. Still getting a size error (please see pic). Any ideas?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Modify Image Colors에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by