DICOMファイルのリサイズにつきまして
    1 visualización (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    ssk
 el 12 de Feb. de 2019
  
    
    
    
    
    Editada: Satoshi Kobayashi
      
 el 17 de Feb. de 2019
            プログラミング初心者です。
現在256*256ピクセルのDICOM画像がございます。
AlexNetで本画像を使用するため、サイズを227 x 227 x 3に変更する必要がございます。
mriVolumeResized = imresize3(mriVolumeOriginal, 0.8867);
sizeR = size(mriVolumeResized);
以上のコードの書き方でよろしいでしょうか。
どうぞよろしくお願いいたします。
0 comentarios
Respuesta aceptada
  Satoshi Kobayashi
      
 el 13 de Feb. de 2019
        mriVolumeOriginalの枚数が不明なので断言はできませんが、
行数、列数および平面数を直接指定した方がよろしいのではないでしょうか。
mriVolumeResized = imresize3(mriVolumeOriginal, [227 227 3]);
4 comentarios
  Satoshi Kobayashi
      
 el 17 de Feb. de 2019
				
      Editada: Satoshi Kobayashi
      
 el 17 de Feb. de 2019
  
			imds = imageDatastore(fullfile(currentdirectory, categories),'IncludeSubfolders',true,'FileExtensions','.dcm','LabelSource', 'foldernames','ReadFcn',@(a)imresize3(dicomread(a), [227 227 3]));
上記コードでaという文字を使ったことに意味はありません。どのフォルダのファイルを読み込む場合も227x227x3として読み込むという意図でした。
本題とは関係ありませんが、imresize3は二次元配列が入力ではエラーとなるので、一枚のときには以下のようにすべきでした。
imds = imageDatastore(fullfile(currentdirectory, categories),'IncludeSubfolders',true,'FileExtensions','.dcm','LabelSource', 'foldernames','ReadFcn',@(a)imresize3(repmat(dicomread(a),1,1,3), [227 227 3]));
さて、本題の全てのサブフォルダーのDICOM画像のリサイズですが、以下のようにして実行可能です。
%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','ReadFcn',@dicomread);
T = countEachLabel(imds);
nOfEachLabel = table2array(T(:,2));
mriVolumeResizeds = cell(length(categories),1);
for m = 1:length(categories)
    imdsTmp = splitEachLabel(imds,nOfEachLabel(m),'Include',categories{m});
    mriVolumeOriginal = cell2mat(permute(readall(imdsTmp),[2,3,1]));
    mriVolumeResized = imresize3(mriVolumeOriginal, [227 227 3]);
    mriVolumeResizeds{m} = mriVolumeResized;
end
この例では、最終出力をセル配列にしましたが、この後の工程によっては三次元か四次元配列の方がよいのかもしれません。
また、リサイズしたものをファイルとして保存する方がよい場合もあります。
Más respuestas (0)
Ver también
Categorías
				Más información sobre DICOM Format en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
