Skip to content

Commit 06f5c7f

Browse files
committed
Improve opencv denoise use case
This commit adds more details about the denoise operation and describes what each of the parameters do. Additional this commit adds an image of the expected output with the recommended starting values.
1 parent 1d4a2c1 commit 06f5c7f

1 file changed

Lines changed: 53 additions & 16 deletions

File tree

docs/ops/doc/examples/opencv_denoise.rst

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,62 @@
22
Fast Non-Local Means Denoise with OpenCV
33
========================================
44

5-
In this example we will use a denoise algorithm defined in an `external libray`_: OpenCV.
5+
In this example we will use a denoise algorithm from the external `OpenCV libray`_.
66

7-
This method progressively scans neighborhoods of an image looking for repeated search template. These
8-
repeated areas can then be averaged to eliminate gaussian noise, without the requirement of additional
7+
This method progressively scans through an image's pixels, comparing a patch centered around
8+
a pixel of interest (*e.g.* a 5x5 patch) with patches from other pixels from the image. These
9+
patches are then averaged to eliminate gaussian noise, without the requirement of additional
910
images for comparison.
1011

11-
Sample data can be found in the `images folder`_.
12-
13-
SciJava Ops via Fiji's sripting engine with `script parameters`_:
12+
The sample data for this example can be downloaded `here`_.
13+
14+
.. figure:: https://media.imagej.net/scijava-ops/1.0.0/opencv_denoise_example_1.png
15+
16+
Results of OpenCV's non-local means denoise algorithm with the sample data.
17+
18+
19+
Denoise parameter descriptions
20+
==============================
21+
22+
+-----------------+-------------------------------------------------------+-------+
23+
| Parameter | Description | Value |
24+
+=================+=======================================================+=======+
25+
| Filter strength | Controls the decay in patch weights as a function |4 |
26+
| | | |
27+
| | of *distance* between patches. The *distance* | |
28+
| | | |
29+
| | between patches is a measure of how similar they | |
30+
| | | |
31+
| | are. Large filter strength values allow more distant | |
32+
| | | |
33+
| | (*i.e.* dissimilar) patches to have more influence on | |
34+
| | | |
35+
| | the denoise output. | |
36+
+-----------------+-------------------------------------------------------+-------+
37+
| Patch size | The size of the patches/blocks from the input image |7 |
38+
| | | |
39+
| | to be compared. Patch sizes should be odd | |
40+
| | | |
41+
| | (default=7). | |
42+
+-----------------+-------------------------------------------------------+-------+
43+
| Search size | The size of the area in the input image to search |21 |
44+
| | | |
45+
| | for similar patches to compare. Search sizes | |
46+
| | | |
47+
| | should be odd (default=21). | |
48+
+-----------------+-------------------------------------------------------+-------+
49+
50+
SciJava Ops via Fiji's scripting engine with `script parameters`_:
1451

1552
.. tabs::
1653

1754
.. code-tab:: scijava-groovy
1855

1956
#@ OpEnvironment ops
2057
#@ ImgPlus img
21-
#@ Integer (label="strength:", value=4.0) strength
22-
#@ Integer (label="template size:", value=7) template
23-
#@ Integer (label="search size:", value=21) search
58+
#@ Integer (label="Filter strength:", value=4) strength
59+
#@ Integer (label="Patch size:", value=7) patch
60+
#@ Integer (label="Search size:", value=21) search
2461
#@output ImgPlus result
2562

2663
import net.imglib2.type.numeric.integer.UnsignedByteType
@@ -43,7 +80,7 @@ SciJava Ops via Fiji's sripting engine with `script parameters`_:
4380
output = img8bit.copy()
4481

4582
// Run the denoise op
46-
ops.quaternary("filter.denoise").input(img8bit, strength, template, search).output(output).compute()
83+
ops.quaternary("filter.denoise").input(img8bit, strength, patch, search).output(output).compute()
4784

4885
// Return the denoised image
4986
result = output
@@ -52,9 +89,9 @@ SciJava Ops via Fiji's sripting engine with `script parameters`_:
5289

5390
#@ OpEnvironment ops
5491
#@ ImgPlus img
55-
#@ Integer (label="strength:", value=4.0) strength
56-
#@ Integer (label="template size:", value=7) template
57-
#@ Integer (label="search size:", value=21) search
92+
#@ Integer (label="Filter strength:", value=4) strength
93+
#@ Integer (label="Patch size:", value=7) patch
94+
#@ Integer (label="Search size:", value=21) search
5895
#@output ImgPlus result
5996

6097
from net.imglib2.type.numeric.integer import UnsignedByteType
@@ -77,11 +114,11 @@ SciJava Ops via Fiji's sripting engine with `script parameters`_:
77114
output = img8bit.copy()
78115

79116
# Run the denoise op
80-
ops.quaternary("filter.denoise").input(img8bit, strength, template, search).output(output).compute()
117+
ops.quaternary("filter.denoise").input(img8bit, strength, patch, search).output(output).compute()
81118

82119
# Return the denoised image
83120
result = output
84121

85122
.. _`script parameters`: https://imagej.net/scripting/parameters
86-
.. _`external libray`: https://docs.opencv.org/4.x/d5/d69/tutorial_py_non_local_means.html
87-
.. _`images folder`: https://github.com/scijava/incubator/tree/main/docs/ops/images/sample_16bit_T24.png
123+
.. _`OpenCV libray`: https://docs.opencv.org/4.x/d5/d69/tutorial_py_non_local_means.html
124+
.. _`here`: https://media.imagej.net/scijava-ops/1.0.0/opencv_denoise_16bit.png

0 commit comments

Comments
 (0)