elerac / polanalyser

Polarization image analysis tool. Demosaicing, Stokes vector, Mueller matrix.
MIT License
135 stars 25 forks source link

Demosaicing implementation #7

Closed marcoromelli closed 5 months ago

marcoromelli commented 5 months ago

Hello and thanks for creating this library.

It is mentioned in the README that for demosaicing "Three algorithms are implemented; Bilinear, Variable Number of Gradients (VNG), Edge-Aware (EA)".

I see in the code that there is actually a single implementation and it is somehow based on the OpenCV DeBayer algorithm. What is actually happening? Is the implemented approach one of the three mentioned in the readme or actually another one?

Thanks.

elerac commented 5 months ago

Hello @marcoromelli

I utilize OpenCV's demosaicing implementation for polarization sensors, and the three algorithms are for OpenCV's codes.

OpenCV's codes are designed for RGB sensors, but parts of the procedure can be shared for polarization. You can see the basic procedure of polarization demosaicing using bilinear interpolation in the prior issue #3 (although this issue is discussed in the old code, but I believe it is helpful to understand the basic). This procedure is identical to a standard RGB sensor's red or blue channels. So, we can apply the same procedure of red or blue channels for polarization sensors.

In Polanalyser, I simply execute OpenCV's demosaicing two times for (0, 90) and (45, 135) and merge them to get the final result (you can see it in __demosaicing_mono). Additional suffixes VNG or EA are for OpenCV. Although these options are designed for RGB sensors, I confirmed EA slightly improves the demosaicing quality.

I know this is a lazy approach and should be replaced with a tailored implementation for polarization. And also, I'm curious about the Python implementation of recent advanced demosaicing methods such as [Qiu+, CGF2021] and [Morimatsu+, ICIP2020]. Unfortunately, I do not have enough time to write these codes.

marcoromelli commented 5 months ago

Thanks @elerac for the fast feedback! Your explanation was very clear.