Using X,Y,Z coordinates and grayscale values of pixels to reconstruct an image
3 ビュー (過去 30 日間)
古いコメントを表示
I am working on a project where I am given the X,Y,Z coordinates of each pixel and the grayscale value of each pixel. The grayscale value is how bright or dark each pixel is (darker pixel is lower value and brighter pixel is higher value). The given Y-coordinate values are zero.
What lines of code would you recommend using to proceed? I have already imported the data.
0 件のコメント
回答 (2 件)
Image Analyst
2021 年 10 月 25 日
Do the xyz values correspond to voxel locations? If so, simply use a for loop to stuff the value into the appropriate voxel.
maxCol = max(x); % x, y, and z are N row by 1 column vectors.
maxRow = max(y);
maxSlice = max(z);
image3d = zeros(maxRow, maxCol, maxSlice, 'uint8'); % or uint16
for k = 1 : length(x)
image3d(y(k), x(k), z(k)) = grayLevel(k);
end
If x, y, and z are floating point or have values way different than the number of voxel dimensions you want, then you can use round(rescale()) to turn them into voxel coordinates before passing to image3d as indexes.
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!