How to incorporate scatter function so that the lines of the image don’t print on top of one another
I have this code to take x.y,z coordinates to make an x-ray image. The lines of the image just print on top of one another. I want to use the scatter function so that the lines of the image make a full picture. How and where would I add this?
Here is my code:
data = readmatrix(‘C:UsersdevinehChest_XRay_Raw_Data.txt’);
% Extract x, y, z coordinates and grayscale values
x = data(:,1);
y = data(:,2);
z = data(:,3); % If needed, otherwise ignore
grayscale = data(:,4);
%Normalize points
x = round(x – min(x) + 1);
y = round(y – min(y) + 1);
%Find bounds
x_range = min(x):max(x);
y_range = min(y):max(y);
% Initialize the image matrix
image = zeros(length(y_range), length(x_range));
% Populate the image matrix with grayscale values
for i = 1:length(x)
x_idx = find(x_range == x(i));
y_idx = find(y_range == y(i));
image(y_idx, x_idx) = grayscale(i);
end
%normalize image
image = mat2gray(image);
% Display the image
imshow(image);
title(‘Reconstructed Image from Raw Data’);I have this code to take x.y,z coordinates to make an x-ray image. The lines of the image just print on top of one another. I want to use the scatter function so that the lines of the image make a full picture. How and where would I add this?
Here is my code:
data = readmatrix(‘C:UsersdevinehChest_XRay_Raw_Data.txt’);
% Extract x, y, z coordinates and grayscale values
x = data(:,1);
y = data(:,2);
z = data(:,3); % If needed, otherwise ignore
grayscale = data(:,4);
%Normalize points
x = round(x – min(x) + 1);
y = round(y – min(y) + 1);
%Find bounds
x_range = min(x):max(x);
y_range = min(y):max(y);
% Initialize the image matrix
image = zeros(length(y_range), length(x_range));
% Populate the image matrix with grayscale values
for i = 1:length(x)
x_idx = find(x_range == x(i));
y_idx = find(y_range == y(i));
image(y_idx, x_idx) = grayscale(i);
end
%normalize image
image = mat2gray(image);
% Display the image
imshow(image);
title(‘Reconstructed Image from Raw Data’); I have this code to take x.y,z coordinates to make an x-ray image. The lines of the image just print on top of one another. I want to use the scatter function so that the lines of the image make a full picture. How and where would I add this?
Here is my code:
data = readmatrix(‘C:UsersdevinehChest_XRay_Raw_Data.txt’);
% Extract x, y, z coordinates and grayscale values
x = data(:,1);
y = data(:,2);
z = data(:,3); % If needed, otherwise ignore
grayscale = data(:,4);
%Normalize points
x = round(x – min(x) + 1);
y = round(y – min(y) + 1);
%Find bounds
x_range = min(x):max(x);
y_range = min(y):max(y);
% Initialize the image matrix
image = zeros(length(y_range), length(x_range));
% Populate the image matrix with grayscale values
for i = 1:length(x)
x_idx = find(x_range == x(i));
y_idx = find(y_range == y(i));
image(y_idx, x_idx) = grayscale(i);
end
%normalize image
image = mat2gray(image);
% Display the image
imshow(image);
title(‘Reconstructed Image from Raw Data’); scatter, grayscale, image MATLAB Answers — New Questions