How to reshape a single column matrix in the following example?
Show older comments
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!
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!