I have around 696 dicom slices(23x56x696). I want to put them all in a single matrix (X) to calcul;ate the mean of the image. I used this code to do so
for i = 1:696
X(:,:,i) = dicomread(sprintf('boneMat1%010i.dcm',i));
end
meanval = mean2(X);
but getting an error message saying "Subscripted assignment dimension mismatch." can anybody please help me to write a script to get the mean value.? I will be thankful to you. Regards, Sumaira Nazir

5 comentarios

Stephen23
Stephen23 el 9 de Mzo. de 2016
Editada: Stephen23 el 9 de Mzo. de 2016
According to the dicomread documentation there are several different image array dimensions: "For single-frame grayscale images, X is an M-by-N array. For single-frame true-color images, X is an M-by-N-by-3 array. Multiframe images are always 4-D arrays."
Do you have true grayscale images? Single frame? Are all of these slices saved in one file?
SUMAIRA NAZIR
SUMAIRA NAZIR el 9 de Mzo. de 2016
I am new to use matlab and processing the dicom images. however, I have grayscale images of bone. but I do'nt know what you mean by single frame?
Stephen23
Stephen23 el 9 de Mzo. de 2016
Please tell us the size of one image:
size(dicomread(sprintf('boneMat1%010i.dcm',1)))
SUMAIRA NAZIR
SUMAIRA NAZIR el 9 de Mzo. de 2016
>> size(dicomread(sprintf('boneMat10000000001.dcm',1)))
ans =
23 56
Jingyang Xie
Jingyang Xie el 7 de Feb. de 2021
Hi Sumaira, have you solved this problem? Thanks!

Iniciar sesión para comentar.

 Respuesta aceptada

Guillaume
Guillaume el 9 de Mzo. de 2016
Editada: Guillaume el 9 de Mzo. de 2016

0 votos

It looks like at least one of your image is not the same size as the other. For now, load the images in a cell array:
imgs = cell(1, 696)
for imgidx = 1:696
imgs{imgidx} = dicomread(sprintf('boneMat1%010i.dcm', imgidx));
end
Then check the size of each image:
[height, width, pages] = cellfun(@size, imgs);
wrongsize = height ~= mode(height) | width ~= mode(width) | pages ~= mode(pages);
wrongsizeindices = find(wrongsize)
wrongsizeindices gives you the index of the images that are different size.

2 comentarios

SUMAIRA NAZIR
SUMAIRA NAZIR el 9 de Mzo. de 2016
wrongsizeindices =
Empty matrix: 1-by-0
Guillaume
Guillaume el 9 de Mzo. de 2016
Ok, then most likely, the matrix X exists before the loop and is not 23x56 to start with. So before your loop, initialise X with:
X = zeros(23, 56, 696);
Or if you still have my imgs cell array hanging around you can simply convert it into a matrix with:
X = cat(3, imgs{:});
meanval = mean2(X);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre DICOM Format en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 9 de Mzo. de 2016

Comentada:

el 7 de Feb. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by