Question: Use MATLAB to: a . Reconstruct the following image from the raw data posted on blackboard ( you first need to unzip the raw data

Use MATLAB to: a. Reconstruct the following image from the raw data posted on blackboard (you first need to unzip the raw data text file). The raw data includes x,y,z coordinates of each pixel in addition to the grayscale value (a measure of brightness/darkness of each pixel with lower values indicating darker pixel).
Here is the data given:DO NOT COPY
DO NOT COPY
DO NOT COPY
Here is the code I have:
data = textscan('Chest_Xray_Raw_Data.txt','%f%f%f%f', 'Delimiter', ',');
% Extract x, y, z coordinates and grayscale values
x = data{1};
y = data{2};
z = data{3}; % If needed, otherwise ignore
grayscale = data{4};
% Determine the size of the image
maxX = int64(max(x));
maxY = int64(max(y));
% Normalize coordinates to fit into the pixel grid
x = round(x - min(x)+1);
y = round(y - min(y)+1);
% Initialize the image matrix
imageMatrix = zeros(maxY, maxX);
% Populate the image matrix with grayscale values
for i =1:length(x)
imageMatrix(y(i), x(i))= grayscale(i);
end
% Display the image
figure;
imshow(imageMatrix,[]);
title('Reconstructed Image from Raw Data');
colormap(gray); % Use grayscale colormap
colorbar;
However, I only get the color bar and no image. How do I fix this?
 Use MATLAB to: a. Reconstruct the following image from the raw

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!