OpenCV 4.5.2: Issues with Denoising a Color Image Using Non-Local Means Denoising
I'm a bit lost with I'm working on a project and hit a roadblock. After trying multiple solutions online, I still can't figure this out. I'm relatively new to this, so bear with me. I'm trying to denoise a color image using OpenCV's Non-Local Means Denoising function, but I'm facing unexpected results. After applying the `fastNlMeansDenoisingColored` function, the output image appears overly smoothed and loses significant detail, especially in textured areas like skin and fabric. Hereβs the code snippet Iβm working with: ```python import cv2 import numpy as np # Read the input image image = cv2.imread('input_image.jpg') # Convert to float32 for better precision in denoising image_float = np.float32(image) # Apply Non-Local Means Denoising # The parameters are: src, dst, h, templateWindowSize, searchWindowSize output = cv2.fastNlMeansDenoisingColored(image_float, None, h=10, templateWindowSize=7, searchWindowSize=21) # Save the output image cv2.imwrite('output_image.jpg', output) ``` I have tried adjusting the `h` parameter from 5 to 30, but the results remain suboptimal. The image becomes overly blurred even at lower values. Additionally, I ensured that the image is in the correct format (BGR), and the data type is set correctly. When I print the output image shape, it matches the input image, which is expected: ```python print(output.shape) # Should match input image dimensions ``` However, I noticed that the loss of detail seems to be more pronounced in certain areas, which leads me to believe that my choice of parameters might not be ideal. Is there a recommended way to fine-tune these parameters for color images, or are there alternative methods for denoising that can retain more detail? Any advice or best practices would be greatly appreciated! This is part of a larger service I'm building. Am I missing something obvious? Has anyone else encountered this? This is happening in both development and production on Windows 10. Any help would be greatly appreciated! This is my first time working with Python 3.11. Any feedback is welcome!