Create image from pixels using two vectors and their grayscale value

5 visualizaciones (últimos 30 días)
I have a very basic understanding of matlab. What I am trying to do is use X,Y,Z datapoints and their grayscale value (how dark or how light the pixel is) to reconstruct an image of a chest X-Ray pixel-by-pixel. I have over 5 million data points and all of the Y data points are zero. I am having a hard time accomplishing it. Do you have any tips? Thank you!
  2 comentarios
DGM
DGM el 26 de Oct. de 2021
Editada: DGM el 26 de Oct. de 2021
How exactly is the data arranged? What are the vector/array sizes? If x and y are vectors and z is a 2D array representing intensity, then you should simply be able to use z without regard for x or y. If x,y,z are positional information and you have a fourth array for intensity information, then you should be able to do the same, as the positional information is constant-valued along one axis (y), implying that all the points are coplanar.
It would help if you could provide an example of the data.
John Smith
John Smith el 26 de Oct. de 2021
Sure, here are is some of my data. Please note that not all of the Z-axis data is 0.1699, there are over 5 million data points and they do eventually change. However, all of the Y-axis data is always 0. Thank you!
X Y Z Grayscale
412.234500000000 0 0.169900000000000 426
412.064600000000 0 0.169900000000000 427
411.894600000000 0 0.169900000000000 427
411.724700000000 0 0.169900000000000 427
411.554800000000 0 0.169900000000000 427
411.384900000000 0 0.169900000000000 429
411.214900000000 0 0.169900000000000 429
411.045000000000 0 0.169900000000000 429
410.875100000000 0 0.169900000000000 429
410.705200000000 0 0.169900000000000 429
410.535200000000 0 0.169900000000000 429

Iniciar sesión para comentar.

Respuesta aceptada

DGM
DGM el 26 de Oct. de 2021
Editada: DGM el 28 de Oct. de 2021
I'm pretty sure there are other ways to do this, but here's one way.
% build example image and position data
A = imread('coins.png').';
[z x] = meshgrid(1:size(A,2),1:size(A,1));
x = 0.1*x(:)+1; % just to show that this works for non-integers
z = 0.1*z(:)+1;
y = zeros(size(x));
A = A(:);
% at this point, you have four vectors
% one way to rectify the image
imheight = numel(unique(z));
imwidth = numel(unique(x));
B = reshape(A,imwidth,imheight).';
imshow(B)
Depending on the class and range of the intensity data, you might need to scale/cast the image in order for it to display or save correctly. I imagine the intensity data was originally int16 or uint16. If it has been cast as double, make sure to either normalize it or cast it back to the original integer class.
EDIT:
If this is the same as this:
the file needs to be read into the workspace so that the vectors are available. This may be one way:
a = dlmread('testfile.txt');
x = a(:,1);
z = a(:,3);
A = mat2gray(a(:,4)); % normalize
In this example, I'm ignoring the format and scaling of the intensity data and just normalizing it. That should result in a properly-scaled image regardless of the original class.

Más respuestas (0)

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by