Ruyi-Zha / naf_cbct

MIT License
106 stars 20 forks source link

question about generateData.py #20

Open 1999kevin opened 2 weeks ago

1999kevin commented 2 weeks ago

Hi, in generateData.py line 178 projections = tigre.Ax(np.transpose(img, (2, 1, 0)).copy(), geo, data["train"]["angles"])[:, ::-1, :], why we need to transpose img from zyx to xyz and then reverse the first axis of the generated projections. Is it related to the coordinate transformation between the world and the camera?

Procat18cn commented 1 week ago

My personal understanding:

When performing Ax forward projection operations, TIGRE's Matlab and Python programs require different dimension definitions of Img. In Matlab, the 1-3 dimensions of the matrix are defined as xyz and in Python as zyx.

The first axis of the reverse projection may be related to the definition of the coordinates of the NAF projection.

1999kevin commented 1 week ago

Actually, I have checked the TIGRE demo (https://github.com/CERN/TIGRE/blob/master/Python/demos/d04_SimpleReconstruction.py). They do not apply the transpose and reverse for the forward projection.

I do not quite understand this operation because they have saved the original image into the pickle file, which should be the ground truth result for the reconstruction algorithm, but use its transposed one to obtain the projection X-ray figures. I guess the reconstruction result should be like the transposed result of the original image, right?

Ruyi-Zha commented 4 days ago

Apologies for the delayed response as I was on vacation. The main reason arises from the coordinate difference, particularly in 2D, between TIGRE and our implementation in OpenCV. As shown below, our 2D projection axis is centered at the top-left, whereas TIGRE's is at the bottom-left. Consequently, to achieve the correct X-ray projection with TIGRE, we transpose the 3D CT image. This transposed CT image is solely utilized for projection synthesis. There are of course alternative methods to obtain the projection, such as transposing the synthesized 2D results directly. Hope this helps.

TIGRE coordinate:

Screenshot 2024-07-12 at 10 52 33 AM

NAF coordinate:

Screenshot 2024-07-12 at 10 53 57 AM