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

조회 수: 1 (최근 30일)
blues
blues 2020년 2월 25일
댓글: blues 2020년 2월 25일
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
blues
blues 2020년 2월 25일
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 2020년 2월 25일
Yes, how can I convert the updated column vectors back to the same shape as in original one?

댓글을 달려면 로그인하십시오.

채택된 답변

Turlough Hughes
Turlough Hughes 2020년 2월 25일
편집: Turlough Hughes 2020년 2월 25일
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;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by