You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/py_tutorials/py_photo/py_non_local_means/py_non_local_means.rst
+11-5Lines changed: 11 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,9 @@ Theory
18
18
19
19
In earlier chapters, we have seen many image smoothing techniques like Gaussian Blurring, Median Blurring etc and they were good to some extent in removing small quantities of noise. In those techniques, we took a small neighbourhood around a pixel and did some operations like gaussian weighted average, median of the values etc to replace the central element. In short, noise removal at a pixel was local to its neighbourhood.
20
20
21
-
There is a property of noise. Noise is generally considered to be a random variable with zero mean. Consider a noisy pixel, :math:`p = p_0 + n` where :math:`p_0` is the true value of pixel and :math:`n` is the noise in that pixel. You can a large number of same pixel (say :math:`N`) from different images and computes their average. Ideally, you should get :math:`p = p_0` since mean of noise is zero.
21
+
There is a property of noise. Noise is generally considered to be a random variable with zero mean. Consider a noisy pixel, :math:`p = p_0 + n` where :math:`p_0` is the true value of pixel and :math:`n` is the noise in that pixel. You can take large number of same pixels (say :math:`N`) from different images and computes their average. Ideally, you should get :math:`p = p_0` since mean of noise is zero.
22
22
23
-
You can verify it yourself by a simple setup. Hold a static camera to a certain location for a couple of seconds. This will give you plenty of frames, or a lot of images of the same scene. Then write a piece of code to find the average of all the frames in the video (This should be too simple for you now ). Compare the final result and first frame. Unfortunately this simple method is not robust to camera and scene motions. Also often there is only one noisy image available.
23
+
You can verify it yourself by a simple setup. Hold a static camera to a certain location for a couple of seconds. This will give you plenty of frames, or a lot of images of the same scene. Then write a piece of code to find the average of all the frames in the video (This should be too simple for you now ). Compare the final result and first frame. You can see reduction in noise. Unfortunately this simple method is not robust to camera and scene motions. Also often there is only one noisy image available.
24
24
25
25
So idea is simple, we need a set of similar images to average out the noise. Consider a small window (say 5x5 window) in the image. Chance is large that the same patch may be somewhere else in the image. Sometimes in a small neigbourhood around it. What about using these similar patches together and find their average? For that particular window, that is fine. See an example image below:
26
26
@@ -97,12 +97,18 @@ Now we will apply the same method to a video. The first argument is the list of
97
97
# convert all to grayscale
98
98
gray = [cv2.cvtColor(i, cv2.COLOR_BGR2GRAY) for i in img]
@@ -114,7 +120,7 @@ Now we will apply the same method to a video. The first argument is the list of
114
120
115
121
Below image shows a zoomed version of the result we got:
116
122
117
-
.. image:: images/nlm_video.jpg
123
+
.. image:: images/nlm_multi.jpg
118
124
:alt:Denoising a frame
119
125
:align:center
120
126
@@ -127,7 +133,7 @@ Additional Resources
127
133
128
134
#. http://www.ipol.im/pub/art/2011/bcm_nlm/ (It has the details, online demo etc. Highly recommended to visit. Our test image is generated from this link)
129
135
130
-
#. Online course at coursera (link to be added)(First image taken from here)
136
+
#. `Online course at coursera <https://www.coursera.org/course/images>`_ (First image taken from here)
0 commit comments