Not getting a full image from raw data
I am trying to make an Xray image using x, y, and z coordinates of raw data. Here is what I have:
data = readmatrix(‘Chest_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);
%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’);
Raw data example:
+4.23789300E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23619400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23449400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23279500E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23109600E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22939700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22769700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22599800E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22429900E+002, +0.00000000E+000, +0.00000000E+000, +420
An image window pops up with only one solid line with a little blank space in the middle. Any suggestions to fix this?I am trying to make an Xray image using x, y, and z coordinates of raw data. Here is what I have:
data = readmatrix(‘Chest_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);
%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’);
Raw data example:
+4.23789300E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23619400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23449400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23279500E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23109600E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22939700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22769700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22599800E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22429900E+002, +0.00000000E+000, +0.00000000E+000, +420
An image window pops up with only one solid line with a little blank space in the middle. Any suggestions to fix this? I am trying to make an Xray image using x, y, and z coordinates of raw data. Here is what I have:
data = readmatrix(‘Chest_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);
%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’);
Raw data example:
+4.23789300E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23619400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23449400E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23279500E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.23109600E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22939700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22769700E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22599800E+002, +0.00000000E+000, +0.00000000E+000, +420
+4.22429900E+002, +0.00000000E+000, +0.00000000E+000, +420
An image window pops up with only one solid line with a little blank space in the middle. Any suggestions to fix this? grayscale, xray, image MATLAB Answers — New Questions