DICOMファイルのデータサイズの読み込み方

6 views (last 30 days)
ssk
ssk on 3 Feb 2019
Commented: ssk on 4 Feb 2019
プログラミング初心者です。
CNNを動かすのにDICOMファイルのデータサイズを必要としています。(データサイズは〇〇pixel ×〇〇pixelという形式を想定しています。)
%path = current directory
currentdirectory = pwd;
% set categories of subdirectory
categories = {'a', 'b', 'c','d'};
imds = imageDatastore(fullfile(currentdirectory, categories),'IncludeSubfolders',true,'FileExtensions','.dcm','LabelSource', 'foldernames');
現在、上のようなコードを書いていて、imageがjpgファイルの場合、以下のようなコードでデータサイズが表示できるようです。
img = readimage(imds,1);
size(img)
DICOMファイルのデータサイズを表示するために、以下のコードを書いてみたのですが動きませんでした。
img = dicomread(imds,1);
size(img)
jpgファイルを表示するコードに即した形で表示できたらと思います。
どうぞよろしくお願いいたします。

Accepted Answer

Satoshi Kobayashi
Satoshi Kobayashi on 4 Feb 2019
二通り提示します。
imds = imageDatastore(fullfile(currentdirectory,categories),'IncludeSubfolders',true,'FileExtensions','.dcm','LabelSource', 'foldernames');
img = dicomread(imds.Files{1});
size(img)
imds = imageDatastore(fullfile(currentdirectory, categories),'IncludeSubfolders',true,'FileExtensions','.dcm','LabelSource', 'foldernames','ReadFcn',@dicomread);
img=readimage(imds,1);
size(img)
  1 Comment
ssk
ssk on 4 Feb 2019
ご回答ありがとうございます。
無事表示されました!

Sign in to comment.

More Answers (0)

Categories

Find more on DICOM Format 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!