gaocong13 / Projective-Spatial-Transformers

Generalizing Spatial Transformers to Projective Geometry with Applications to 2D/3D Registration
110 stars 21 forks source link

The output image of the projection is compressed. #14

Closed rassaire closed 2 years ago

rassaire commented 2 years ago

Hello, I am using ProSTGrid to render a 2D image from a CT, but I get the output image which is compressed. I have attached an example of the compressed images I get as output. I would like to get the correct projection. I even changed the size of the output image (which is ray_proj_mov in the code) but the object in the image is still compressed.

Can anyone help me?

image

gaocong13 commented 2 years ago

Hi, this image looks weird. Could you please provide more information about your CT and the ProST rendering code you used?

rassaire commented 2 years ago

Hi @gaocong13

here is my code,

def projection_numpy(CT_PATH, SEG_PATH, BATCH_SIZE, device):
    PI = 3.1415926

    param, det_size, _3D_vol, CT_vol, ray_proj_mov, corner_pt, norm_factor = input_param(CT_PATH, SEG_PATH,
                                                                                         BATCH_SIZE)
    manual_rtvec_gt = np.array([[0, 0, 0, 0, 0, 0]])
    manual_rtvec_smp = np.array([[0.0, 5.0, 5.0, 5.0, 0.0, 0.0]])

    # Normalization and conversion to transformation matrix
    manual_rtvec_smp[:, :3] = manual_rtvec_smp[:, :3] * PI / 180
    manual_rtvec_smp[:, 3:] = manual_rtvec_smp[:, 3:] / norm_factor
    transform_mat3x4_gt, rtvec, rtvec_gt = init_rtvec_test(device, manual_test=True,
                                                           manual_rtvec_gt=manual_rtvec_gt,
                                                           manual_rtvec_smp=manual_rtvec_smp)
    projmodel = ProST(param).to(device)

    target = projmodel(_3D_vol, ray_proj_mov, rtvec_gt, corner_pt)
    min_tar, _ = torch.min(target.reshape(BATCH_SIZE, -1), dim=-1, keepdim=True)
    max_tar, _ = torch.max(target.reshape(BATCH_SIZE, -1), dim=-1, keepdim=True)
    target = (target.reshape(BATCH_SIZE, -1) - min_tar) / (max_tar - min_tar)
    target = target.reshape(BATCH_SIZE, 1, det_size, det_size)
    target = target.detach().cpu().numpy()[0, 0, :, :].reshape(det_size, det_size)
    # target_numpy0 = target_numpy0.reshape((det_size, det_size))

    return target

I can share my CTs with you to test if you don't mine. My CTs are just synthetic data that I generated with another code; but the TCs look correct when I open them with another software.

gaocong13 commented 2 years ago

Hi, could you share your CT to cgao11@jhu.edu? I can take a look offline and see what’s happening.

rassaire commented 2 years ago

Thanks @gaocong13 I have shared it with you.