Using X,Y,Z coordinates and grayscale values of pixels to reconstruct an image

조회 수: 2 (최근 30일)
John Smith
John Smith 2021년 10월 25일
답변: yanqi liu 2021년 10월 26일
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.

답변 (2개)

Image Analyst
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.

yanqi liu
yanqi liu 2021년 10월 26일
sir,may be use .off、.obj and so on to generate 3D file,such as

제품

Community Treasure Hunt

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

Start Hunting!

Translated by