Python implementation of the algorithm in the paper "A Fusion-based Enhancing Method for Weakly Illuminated Images".
a. Go to the project directory.
cd Multi-scale_FE/b. Generate illumination enhanced image.
python multi_scale_fe.py --input_path ${INPUT_PATH} (optional: --level ${LEVEL})Please replace ${INPUT_PATH} and ${LEVEL} in the shell of the command line with the real input image path and the number of layers.
The multi_scale_fe.py script has undergone several optimizations to improve its performance and efficiency:
box_filterOptimization: The original cumulative sum-basedbox_filterwas replaced withcv2.boxFilter(..., normalize=False, borderType=cv2.BORDER_REPLICATE), leveraging OpenCV's highly optimized implementation for sum-based box filtering.guided_filterEfficiency: The calculation of the window area (N) within theguided_filterwas changed from abox_filtercall on an array of ones to a direct scalar computation (N = (2 * rad + 1)**2), saving a full image filtering operation.- OpenCV Pyramid Functions: The manual Gaussian pyramid construction functions (
pyramid_reduceandpyramid_expand) were replaced with OpenCV's optimizedcv2.pyrDownandcv2.pyrUpfunctions, respectively. Thegenerate_pyramidfunction was updated to use these standard functions, ensuring correct size handling for Laplacian pyramid construction. - Vectorized Structuring Element: The loop-based generation of the structuring element (
struct_elem) infusion_based_methodwas replaced with direct NumPy array assignments for improved efficiency. - Redundancy Reduction: Unnecessary data type conversions (e.g., redundant
np.double()calls on already float64 arrays) were removed in several parts of the code, particularly in pyramid generation and image resizing loops. - General Python Cleanups:
- Unused imports (
math,scipy.signal) were removed. math.piwas replaced withnp.pi.- Non-essential
matplotlib.pyplot.show()calls were commented out to make the script suitable for non-interactive execution, relying onplt.imsave()for output.
- Unused imports (
These optimizations contribute to a more streamlined, faster, and more efficient execution of the image enhancement process.