How to reshape a single column matrix in the following example?

1 visualización (últimos 30 días)
I have a CT dicom files (512*512*263), I wanted to play with the CT numbers (HU) in the following way: (a) multiply the voxels that have CT number less than 20 by 2 (say, for fun, I want to understand how this works) and (b) multiply the voxels that have CT numbers greater than 20 by 10. I wrote the following code, find below.
In the code I splitted the CT_number into two parts and worked on it, now I want to combine the results such that the new column vector 1D will have the updated values. How can I do that? Shouldn't be hard I guess, but I lost. ANy help would be helpful.
CT_matrix = zeros(512, 512, 263); % preallocate the image array
info_ct = dicominfo('...01.IMA');
for p = 1:263
CTfilename = sprintf('..-%03d.IMA', p);
CT_matrix(:,:,p) = dicomread(CTfilename);
end
% Convert CT matrix into a column vector to assess the voxel values
idx = CT_matrix(:); % idx is a column vector
CT_number = idx ;
% voxels that have CT numbers less than 20 (say)
voxels_have_CT_number_less_than_20 = CT_number(CT_number < 20);
% Multiply the voxels_have_CT_number_less_than_20 by 2
new_voxels_have_CT_number_less_than_20 = voxels_have_CT_number_less_than_20 * 2;
% voxels that have CT numbers greater than 20 (say)
voxels_have_CT_number_greater_than_20 = CT_number(CT_number > 20);
% Multiply the voxels_have_CT_number_greater_than_20 by 10
new_voxels_have_CT_number_greater_than_20 = voxels_have_CT_number_greater_than_20 * 10;
% Now, I want to create a 1D matrix (by combining new_voxels_have_CT_number_less_than_20 and new_voxels_have_CT_number_greater_than_20)
% such that I can see the matrix oprtaion in a single column.
% Then, I can reshape this matrix to the original CT dimension
new_CT_map = reshape(.., size(CT_matrix)); % not sure how to complete this!
  2 comentarios
blues
blues el 25 de Feb. de 2020
After matrix manipulation, I had two vectors in above example. One is new_voxels_have_CT_number_less_than_20 and other is new_voxels_have_CT_number_greater_than_20. Both of them actually belongs to CT_number (1D column) vector.
My question is how can I combine the results of these new_voxels_have_CT_number_less_than_20 and new_voxels_have_CT_number_greater_than_20, so that I can make a new colmun vector (1D), then finally I can use reshape function to make a original size CT matrix?
blues
blues el 25 de Feb. de 2020
Yes, how can I convert the updated column vectors back to the same shape as in original one?

Iniciar sesión para comentar.

Respuesta aceptada

Turlough Hughes
Turlough Hughes el 25 de Feb. de 2020
Editada: Turlough Hughes el 25 de Feb. de 2020
If you write the following you can directly modify the CT_matrix, no need to separate it out into a column vector:
ind_lte_20 = CT_matrix<=20; % index for values less than or equal to 20.
ind_gt_20 = CT_matrix>20; % index for values greater than 20.
CT_matrix(ind_lte_20) = CT_matrix(ind_lte_20)*2;
CT_matrix(ind_gt_20) = CT_matrix(ind_gt_20)*10;

Más respuestas (0)

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!

Translated by