Converting large stack of 2D images into 3D image: how to improve performance?

20 ビュー (過去 30 日間)
I am working on a large stack of image data from micro CT and im looking to improve the performance of my code. I have around 600-900 500x500px images that im converting into a 3D stack using a for loop
[file,path]=uigetfile(*.tif,'multiselect','on')
[size_x,size_y]=size(file);
for i=1:size_x
images_2D{i} = imread(file{i});
image_stack = cat(3,image_stack,images_2D{i});
end
I'm finding that sometimes it can be bit slow when using the desirable amount of images ~700, but works fine with 20-100 images. Could this process be changed so it can run in parallel as I dont think it can at the moment and keep the images in order.

採用された回答

Subhadeep Koley
Subhadeep Koley 2019 年 11 月 4 日
Hi, instead of for loop you can use parfor loop for better performance. Refer to the code below.
[file,path]=uigetfile('*.*','multiselect','on');
[size_x,size_y]=size(file);
image_stack = [];
parfor i=1:size_y
tempImage = imread(file{i});
image_stack(:,:,i) = tempImage;
end
Hope this helps!
  1 件のコメント
Rose Lakatos
Rose Lakatos 2019 年 11 月 5 日
This excatly what I was hoping to do thank you so much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by