title: Image restoration to enhance details with OpenCV
body: <p>I'm trying to restore and enhance image details on several photos. I've tried to bring out details by increasing sharpness with <code>cv2.filter2D()</code> and <a href="https://en.wikipedia.org/wiki/Kernel_(image_processing)" rel="nofollow noreferrer">simple kernels</a>. </p>
  
  <p>I've tried an edge detection kernel</p>
  
  <pre><code>[-1 -1 -1]
  [-1  9 -1]
  [-1 -1 -1]
  </code></pre>
  
  <p>and a sharpen kernel</p>
  
  <pre><code>[ 0 -1  0]
  [-1  5 -1]
  [ 0 -1  0]
  </code></pre>
  
  <p>but the results look grainy and unnatural. To smooth out the noise, I've tried blurring techniques such as <code>cv2.medianBlur()</code> and <code>cv2.GaussianBlur()</code> but the results don't come out that great. The images have hazy backgrounds or are dark which makes the features hard to distinguish. Is there a better way to bring out more details especially in the background? Open to both Python or C++ </p>
  
  <p>Input images</p>
  
  <p><a href="https://i.stack.imgur.com/PUp89.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PUp89.jpg" alt="enter image description here"></a></p>
  
  <p>Current results
  <a href="https://i.stack.imgur.com/7ilvm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7ilvm.png" alt="enter image description here"></a></p>
  
  <pre><code>import numpy as np
  import cv2
  
  img = cv2.imread('people.jpg')
  grayscale = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  
  # edge_kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]])
  sharpen_kernel = np.array([[0,-1,0], [-1,5,-1], [0,-1,0]])
  img = cv2.filter2D(grayscale, -1, sharpen_kernel)
  
  # Smooth out image
  # blur = cv2.medianBlur(img, 3)
  blur = cv2.GaussianBlur(img, (3,3), 0)
  
  cv2.imshow('img',img)
  cv2.imwrite('img.png',img)
  cv2.imshow('blur',blur)
  cv2.waitKey(0)
  </code></pre>