faebstn96 / trainable-bilateral-filter-source

This is our implementation of a trainable bilateral filter layer (PyTorch)
Apache License 2.0
49 stars 2 forks source link

3D case example #1

Closed cs123951 closed 2 years ago

cs123951 commented 2 years ago

Hi, I am grateful that you have shared such awesome codes. I have downloaded the codes and tested 2D case. It works well. But when I used 3D images, the results seemed weird. As shown below. image

The input 3D image is like this: image

Could you provide 3D demo case? Thank you very much!

faebstn96 commented 2 years ago

Hi @cs123951,

Thank you for trying out the filter layer. The example_filter.py and example_optimization.py already contain 3D examples. You just have to set n_epochs to a value larger than 1. The result can then be viewed from a different axis by indexing the prediction differently, e.g., prediction[0, 0, :, idx_center, :] instead of prediction[0, 0, :, :, idx_center]. Currently for n_epochs >1 the 2D cameraman picture is repeated n_epochs times in z dimension, which does not create a very interesting 3D phantom. However, you can just load you own phantom: tensor_gt = torch.tensor(load_my_phantom()). The dimensions of the filter input tensor must then be [Batch, Channel, X, Y, Z] (e.g., [1, 1, 128, 128, 128]).

Good luck with the denoising and please let me know if you still encounter problems!

cs123951 commented 2 years ago

Thank you! I have fixed my problem! I added .contiguous() to the image array and my problem has solved, This 3D example in example_optimization.py really helps me!