回帰用の画像データセットの作成
Show older comments
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
on 12 Feb 2022
提示されたプログラムの内容からは、imread関数の出力がimshow関数の入力に(加工されて)渡されるようなので、読み込んだ画像が出力出来ていると想定します。
従って「imread関数で期待通りに画像データを読み込めているかどうか」に絞り込んで不具合の原因を探すべきだと思います。
拓 青柳
on 12 Feb 2022
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
Accepted Answer
More Answers (0)
Categories
Find more on グラフィックス オブジェクトの識別 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!