回帰用の画像データセットの作成

3 views (last 30 days)
拓 青柳
拓 青柳 on 12 Feb 2022
Commented: 拓 青柳 on 12 Feb 2022
matlab初心者です。
・コード
xtrain=zeros(224,224,3,924);
for i=1:924;
I=imread(tra(i));
xtrain(:,:,:,i)=I;
end
%任意の20枚を表示
numTrainImages = numel(ytrain);
figure
idx = randperm(numTrainImages,20);
for i = 1:numel(idx)
subplot(4,5,i)
imshow(xtrain(:,:,:,idx(i)))
end
以上のように回帰用の画像データセットを作り、うち20枚を表示したところ添付画像のようになりました。
四角の外の部分は0パディングした部分なのでこのままで良いのですが、本来X線画像が写っているはずの四角の中が白く抜けてしまいました。どうしたら良いでしょうか。ご教授いただきたいです。
  4 Comments
Atsushi Ueno
Atsushi Ueno on 12 Feb 2022
Edited: Atsushi Ueno on 12 Feb 2022
こういう事ですね
xtrain1 = uint8(zeros(256,256,1,1));
xtrain2 = double(zeros(256,256,1,1));
I = imread('cameraman.tif');
xtrain1(:,:,:,1) = I; % uint8型(0-255)
xtrain2(:,:,:,1) = im2double(I); % double型(0-1)
subplot(2,2,1)
imshow(xtrain1(:,:,:,1)) % uint8型で0-255を画像として表示(正しく表示)
subplot(2,2,2)
imshow(xtrain2(:,:,:,1)) % double型で0-1を画像として表示(正しく表示)
subplot(2,2,3)
imshow(double(xtrain1(:,:,:,1))) % double型で0-255を画像として表示(真っ白)←これが起きていると推定
subplot(2,2,4)
imshow(uint8(xtrain2(:,:,:,1))) % uint8型で0-1を画像として表示(真っ黒)
拓 青柳
拓 青柳 on 12 Feb 2022
できました!
ありがとうございますm(_ _)m
また見かけたら助けていただけると幸いです。

Sign in to comment.

Accepted Answer

Atsushi Ueno
Atsushi Ueno on 12 Feb 2022
xtrain=uint8(zeros(224,224,3,924));
と、変数xtrainをuint8型にすれば白く表示される問題が解消されると想定します

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!