Converting 3d image stack to a 1* 1 cell array

6 Ansichten (letzte 30 Tage)
bhavya vendra
bhavya vendra am 19 Apr. 2016
Kommentiert: bhavya vendra am 20 Apr. 2016
I need to create a 1*1 cell array which has a 3 dimensional (1024*1024*80) array of gray scale values obtained from my image stack.
This is the code I have so far and I am not sure why I cant capture the 3rd dimension but when I run it I can capture 1024*1024 but not the 80 in the z dimension. How can I fix that?
if true
%
clear all
clc
folder = 'E:\Users\bvendra\Desktop\4.13umgs3-14c2before20,30, almost40\20\tif';
D = 'E:\Users\bvendra\Desktop\4.13umgs3-14c2before20,30, almost40\20\tif';
dCell = dir([D,'.tif']);
% NOTE: CHANGE FILETYPE AS APPROPRIATE FOR EACH SEQUENCE (.png, *.bmp, or *.jpg)
N = 80
numRows = ceil(sqrt(N));
IMAGES = cell(1,N);
FNAMEFMT = '%d.tif';
% Load images
for i=1:N
a = imread(sprintf(FNAMEFMT, i));
end
a={a};
save vol01
end

Akzeptierte Antwort

Image Analyst
Image Analyst am 19 Apr. 2016
Bearbeitet: Image Analyst am 19 Apr. 2016
You keep overwriting the "a" variable over and over again. To put it into slices, do this
for k = 1 : N
a2d = imread(sprintf(FNAMEFMT, k));
if k == 1
a3d = a2d;
else
a3d = cat(3, a3d, a2d);
end
end
cellArray = {a3d};
By the way, sticking the 3d array into a cell is dumb.
  1 Kommentar
bhavya vendra
bhavya vendra am 20 Apr. 2016
Thank you!! you are a lifesaver! I was trying to put it in a cell because a different code I am trying to use for my research requires it that way :/

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by