Filter löschen
Filter löschen

Storing pixel information in 4D array..

1 Ansicht (letzte 30 Tage)
Shaun
Shaun am 17 Feb. 2015
Bearbeitet: Stephen23 am 17 Feb. 2015
Hi,
So I have a set (a stack?) of 2D images and I have them stored in a 3D array. I now want to compare pixel values throughout the images, so I would compare...
images(1,1,1), images(1,1,2), images(1,1,3) etc...
and then
images(1,2,1), images(1,2,2), images(1,2,3) etc...
So far I have...
for j = 1:length(dat) [img, map] = dicomread(char(dat(j,1))); images(:,:,j) = img; end
valsZ = cell(size(images, 3), 2); valsX = cell(size(images, 3), 2, size(images, 2));
for x = 1:size(images, 2)
for z = 1:size(images, 3)
imgVal = images(y,x,z);
valsZ(z,:) = {z, imgVal};
end
valsX(x,:,:) = {x, valsZ(1,:), valsZ(2,:)};
end
I think I would need to create a 4D array to store the pixel information so that I have a 2D array of pixel value and image number within a 3D array that defines which column the data is in and then a 4D array for which row the data is in.
At the moment I am getting a 'Subscripted assignment dimension mismatch' error for valsX. Any help would be great! Thanks!

Akzeptierte Antwort

Stephen23
Stephen23 am 17 Feb. 2015
Bearbeitet: Stephen23 am 17 Feb. 2015
It sounds complicated. Why not just use the images array that you have now? MATLAB indexing lets you access rows and slices of any matrix or array, very easily. For example, to get these values in a vector:
images(1,1,1), images(1,1,2), images(1,1,3), etc
just use
images(1,1,:)
which you can then use to perform any kind of comparison or operation on, including any vectorized operations .
  1 Kommentar
Shaun
Shaun am 17 Feb. 2015
Thanks, I did try that but not in the right way!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu DICOM Format finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by