How can I convert my 3 columns data to a .raw image file so that I can read it as an image?

1 回表示 (過去 30 日間)
blues
blues 2021 年 8 月 24 日
コメント済み: KSSV 2021 年 8 月 24 日
Dear users,
I am working on some simulations and output of the simulations are in 3D matrix but the data values are stored in .csv file, with voxel ID's. The voxel ID (iX, iY, and iZ): 0,0,0 is located at the corner of the 3D image as in nucler medicine images. Data is 10x10x10 matrix. Therefore, the center voxel of the 3D matrix is 5,5,5. See the data format in a sceenshot below:
....................................... up to 10, 10, 10 voxels.
I want to calculate the relationship of dose vs distance. So, I need to calculate the radial averaging of the dose as a function of radial distance as I put my sources at the center of the matrix. Could anyone of you help me by providing some clue on this? Any help would be greatly appreciated. I am thinking about converting it to the 3D image array so that I could easily manipulate it and plot the desired relationship.

回答 (1 件)

KSSV
KSSV 2021 年 8 月 24 日
Let A be your matrix of three columns.
x = A(:,1) ; y = A(:,2) ; z = A(:,3) ;
%%structured
xi = unique(x) ; yi = unique(y) ;
[X,Y] = meshgrid(xi,yi) ;
Z = reshape(z,size(X)) ;
figure
pcolor(X,Y,Z)
shading interp
figure
imagesc(Z)
  6 件のコメント
blues
blues 2021 年 8 月 24 日
編集済み: blues 2021 年 8 月 24 日
Thanks for this: table2array function.
Now, I have a meshgrid of desired matrix size. How could I assign the 4th column (i.e. data) into the respective voxels? Following line works for this, right?
Dose_matrix =reshape(Dose, size(X));
KSSV
KSSV 2021 年 8 月 24 日
Yes it should work....

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by