Saturday, 29 July 2023

How to do image pre-processing for depth from focus/defocus using Laplacian using python and opencv?

I have been trying to replicate same results given in the following git repos,

  1. https://github.com/cw1204772/depth_from_focus/tree/master
  2. https://github.com/sangminwoo/Depth_from_Focus/tree/master
  3. https://github.com/iSarmad/Depth-From-Defocus-Matlab/tree/master

I have cloned these repos, but for some reason, I can not generate same depth map as given in the results (in readme) of those repos. Only different thing is my python environment. I am using latest python libs. but I do not get any errors using latest lib. so I am guessing it is fine. Only 1 weird thing is that when I am using these images/datasets https://github.com/cw1204772/depth_from_focus/tree/master/data/keyboard (I am guessing it is pre-processed) I get expected results. but if I used different images such as https://github.com/iSarmad/Depth-From-Defocus-Matlab/tree/master/PA1_dataset2_keyboard. I do not get correct depth map.

What I have tried,

  1. tried changes Laplacian and gaussian kernel size
  2. tried sharpening input images
  3. tried normalizing images
  4. tried resizing PA1_dataset2_keyboard image to the same as https://github.com/cw1204772/depth_from_focus/tree/master/data/keyboard -> 640x360

I have spent 1 week playing with this repos. but I could not get proper depth map. Please help me with this issue. I think I am making some silly error.

my all-in-focus image looks ok, but depth map is looking like following, ![![enter image description here

Thank you very much in advanced.



from How to do image pre-processing for depth from focus/defocus using Laplacian using python and opencv?

No comments:

Post a Comment