Skip to content

Commit 1596d33

Browse files
committed
docs2test for imagebufAlgo image enhancement and restoration section - tests passing on intel
Signed-off-by: Daniel Greenstein <[email protected]>
1 parent 2609729 commit 1596d33

File tree

10 files changed

+196
-49
lines changed

10 files changed

+196
-49
lines changed

src/doc/imagebufalgo.rst

Lines changed: 64 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,24 +2535,27 @@ Image Enhancement / Restoration
25352535

25362536
Examples:
25372537

2538-
.. tabs::
2539-
2540-
.. code-tab:: c++
2538+
.. tabs::
25412539

2542-
ImageBuf Src ("tahoe.exr");
2543-
int pixelsFixed = 0;
2544-
ImageBufAlgo::fixNonFinite (Src, Src, ImageBufAlgo::NONFINITE_BOX3,
2545-
&pixelsFixed);
2546-
std::cout << "Repaired " << pixelsFixed << " non-finite pixels\n";
2540+
.. tab:: C++
2541+
.. literalinclude:: ../../testsuite/docs-examples-cpp/src/docs-examples-imagebufalgo.cpp
2542+
:language: c++
2543+
:start-after: BEGIN-imagebufalgo-fixNonFinite
2544+
:end-before: END-imagebufalgo-fixNonFinite
2545+
:dedent: 4
25472546

2548-
.. code-tab:: py
2547+
.. tab:: Python
2548+
.. literalinclude:: ../../testsuite/docs-examples-python/src/docs-examples-imagebufalgo.py
2549+
:language: py
2550+
:start-after: BEGIN-imagebufalgo-fixNonFinite
2551+
:end-before: END-imagebufalgo-fixNonFinite
2552+
:dedent: 4
25492553

2550-
Src = ImageBuf("tahoe.exr")
2551-
ImageBufAlgo.fixNonFinite (Src, Src, "box3", oiio.NONFINITE_BOX3)
2554+
.. tab:: oiiotool
2555+
.. sourcecode:: bash
25522556

2553-
.. code-tab:: bash oiiotool
2557+
oiiotool with_nans.tif --fixnan box3 -o with_nans_fixed.tif
25542558

2555-
oiiotool tahoe.exr --fixnan box3 -o fixed.exr
25562559

25572560
|
25582561
@@ -2564,21 +2567,27 @@ Image Enhancement / Restoration
25642567

25652568
Examples:
25662569

2567-
.. tabs::
25682570

2569-
.. code-tab:: c++
2570-
2571-
ImageBuf Src ("holes.exr");
2572-
ImageBuf Filled = ImageBufAlgo::fillholes_pushpull (Src);
2571+
.. tabs::
25732572

2574-
.. code-tab:: py
2573+
.. tab:: C++
2574+
.. literalinclude:: ../../testsuite/docs-examples-cpp/src/docs-examples-imagebufalgo.cpp
2575+
:language: c++
2576+
:start-after: BEGIN-imagebufalgo-fillholes_pushpull
2577+
:end-before: END-imagebufalgo-fillholes_pushpull
2578+
:dedent: 4
25752579

2576-
Src = ImageBuf("holes.exr")
2577-
Filled = ImageBufAlgo.fillholes_pushpull (Src)
2580+
.. tab:: Python
2581+
.. literalinclude:: ../../testsuite/docs-examples-python/src/docs-examples-imagebufalgo.py
2582+
:language: py
2583+
:start-after: BEGIN-imagebufalgo-fillholes_pushpull
2584+
:end-before: END-imagebufalgo-fillholes_pushpull
2585+
:dedent: 4
25782586

2579-
.. code-tab:: bash oiiotool
2587+
.. tab:: oiiotool
2588+
.. sourcecode:: bash
25802589

2581-
oiiotool holes.exr --fillholes -o filled.exr
2590+
oiiotool checker_with_alpha.exr --fillholes -o checker_with_alpha_filled.exr
25822591

25832592
|
25842593
@@ -2590,21 +2599,27 @@ Image Enhancement / Restoration
25902599

25912600
Examples:
25922601

2593-
.. tabs::
2594-
2595-
.. code-tab:: c++
25962602

2597-
ImageBuf Noisy ("tahoe.exr");
2598-
ImageBuf Clean = ImageBufAlgo::median_filter (Noisy, 3, 3);
2603+
.. tabs::
25992604

2600-
.. code-tab:: py
2605+
.. tab:: C++
2606+
.. literalinclude:: ../../testsuite/docs-examples-cpp/src/docs-examples-imagebufalgo.cpp
2607+
:language: c++
2608+
:start-after: BEGIN-imagebufalgo-median_filter
2609+
:end-before: END-imagebufalgo-median_filter
2610+
:dedent: 4
26012611

2602-
Noisy = ImageBuf("tahoe.exr")
2603-
Clean = ImageBufAlgo.median_filter (Noisy, 3, 3)
2612+
.. tab:: Python
2613+
.. literalinclude:: ../../testsuite/docs-examples-python/src/docs-examples-imagebufalgo.py
2614+
:language: py
2615+
:start-after: BEGIN-imagebufalgo-median_filter
2616+
:end-before: END-imagebufalgo-median_filter
2617+
:dedent: 4
26042618

2605-
.. code-tab:: bash oiiotool
2619+
.. tab:: oiiotool
2620+
.. sourcecode:: bash
26062621

2607-
oiiotool tahoe.exr --median 3x3 -o clean.exr
2622+
oiiotool tahoe.tif --median 3x3 -o tahoe_median_filter.tif
26082623

26092624
..
26102625
@@ -2633,21 +2648,26 @@ Image Enhancement / Restoration
26332648

26342649
Examples:
26352650

2636-
.. tabs::
2637-
2638-
.. code-tab:: c++
2639-
2640-
ImageBuf Blurry ("tahoe.exr");
2641-
ImageBuf Sharp = ImageBufAlgo::unsharp_mask (Blurry, "gaussian", 5.0f);
2651+
.. tabs::
26422652

2643-
.. code-tab:: py
2653+
.. tab:: C++
2654+
.. literalinclude:: ../../testsuite/docs-examples-cpp/src/docs-examples-imagebufalgo.cpp
2655+
:language: c++
2656+
:start-after: BEGIN-imagebufalgo-unsharp_mask
2657+
:end-before: END-imagebufalgo-unsharp_mask
2658+
:dedent: 4
26442659

2645-
Blurry ImageBuf("tahoe.exr")
2646-
Sharp = ImageBufAlgo.unsharp_mask (Blurry, "gaussian", 5.0)
2660+
.. tab:: Python
2661+
.. literalinclude:: ../../testsuite/docs-examples-python/src/docs-examples-imagebufalgo.py
2662+
:language: py
2663+
:start-after: BEGIN-imagebufalgo-unsharp_mask
2664+
:end-before: END-imagebufalgo-unsharp_mask
2665+
:dedent: 4
26472666

2648-
.. code-tab:: bash oiiotool
2667+
.. tab:: oiiotool
2668+
.. sourcecode:: bash
26492669

2650-
oiiotool tahoe.exr --unsharp:kernel=gaussian:width=5 -o sharp.exr
2670+
oiiotool tahoe.tif --unsharp:kernel=gaussian:width=5 -o tahoe_unsharp_mask.tif
26512671

26522672
|
26532673

src/include/OpenImageIO/imagebufalgo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ enum NonFiniteFixMode
16931693
///< values, if any nonfinite values are found.
16941694
};
16951695

1696-
/// `fixNonFinite()` returns in image containing the values of `src` (within
1696+
/// `fixNonFinite()` returns an image containing the values of `src` (within
16971697
/// the ROI), while repairing any non-finite (NaN/Inf) pixels. If
16981698
/// `pixelsFixed` is not nullptr, store in it the number of pixels that
16991699
/// contained non-finite value. It is permissible to operate in-place (with
55.5 KB
Binary file not shown.

testsuite/common/with_nans.tif

536 KB
Binary file not shown.

testsuite/docs-examples-cpp/ref/out.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ example_absdiff
3333
example_abs
3434
example_mul
3535
example_div
36+
example_fixNonFinite
37+
Repaired 48 non-finite pixels
38+
example_fillholes_pushpull
39+
example_median_filter
40+
example_unsharp_mask
3641
example_make_texture
3742
zero1.exr : 512 x 512, 3 channel, half openexr
3843
SHA-1: 95823C334FCE55968E8D2827CCD1CF77CEE19ABD
@@ -126,6 +131,12 @@ mul.exr : 256 x 256, 4 channel, half openexr
126131
SHA-1: ECCDBBBF088912F0B77B887D6B8B480C3F93615E
127132
div.exr : 256 x 256, 4 channel, half openexr
128133
SHA-1: 6A85C923DB82C893C0D88028386F1C58604A4757
134+
checker_with_alpha_filled.exr : 256 x 256, 4 channel, half openexr
135+
SHA-1: B245E027638D5C1BA2608FEDDB3BB9B5E9FA3A44
136+
tahoe_median_filter.tif : 512 x 384, 3 channel, uint8 tiff
137+
SHA-1: A0B2E3A10A16EA8CC905F144C5F91B6A0964A177
138+
tahoe_unsharp_mask.tif : 512 x 384, 3 channel, uint8 tiff
139+
SHA-1: D3B56074F48EC5D3ADDA4BDE1F487192ABE9BA76
129140
Comparing "simple.tif" and "ref/simple.tif"
130141
PASS
131142
Comparing "scanlines.tif" and "ref/scanlines.tif"

testsuite/docs-examples-cpp/run.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
command += run_app("cmake -E copy " + test_source_dir + "/../common/tahoe-small.tif tahoe.tif")
1616
command += run_app("cmake -E copy " + test_source_dir + "/../common/grid-small.exr A.exr")
1717
command += run_app("cmake -E copy " + test_source_dir + "/../common/grid-small.exr B.exr")
18-
18+
command += run_app("cmake -E copy " + test_source_dir + "/../common/with_nans.tif with_nans.tif")
19+
command += run_app("cmake -E copy " + test_source_dir + "/../common/checker_with_alpha.exr checker_with_alpha.exr")
1920

2021
# Copy the grid to both a tiled and scanline version
2122
command += oiio_app("iconvert") + "../common/grid.tif --scanline scanline.tif > out.txt ;"
@@ -83,7 +84,10 @@
8384
"absdiff.exr",
8485
"abs.exr",
8586
"mul.exr",
86-
"div.exr"
87+
"div.exr",
88+
"checker_with_alpha_filled.exr",
89+
"tahoe_median_filter.tif",
90+
"tahoe_unsharp_mask.tif"
8791
]
8892
for file in hashes :
8993
command += info_command(file, verbose=False)

testsuite/docs-examples-cpp/src/docs-examples-imagebufalgo.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,60 @@ void example_div()
583583

584584
// Section: Image enhancement / restoration
585585

586+
void example_fixNonFinite()
587+
{
588+
print("example_fixNonFinite\n");
589+
// BEGIN-imagebufalgo-fixNonFinite
590+
ImageBuf Src ("with_nans.tif");
591+
int pixelsFixed = 0;
592+
ImageBufAlgo::fixNonFinite (Src, Src, ImageBufAlgo::NONFINITE_BOX3,
593+
&pixelsFixed);
594+
std::cout << "Repaired " << pixelsFixed << " non-finite pixels\n";
595+
// END-imagebufalgo-fixNonFinite
596+
597+
// fixing the nans seems nondeterministic - so not writing out the image
598+
// Src.write("with_nans_fixed.tif");
599+
600+
}
601+
602+
603+
void example_fillholes_pushpull()
604+
{
605+
print("example_fillholes_pushpull\n");
606+
// BEGIN-imagebufalgo-fillholes_pushpull
607+
608+
ImageBuf Src ("checker_with_alpha.exr");
609+
ImageBuf Filled = ImageBufAlgo::fillholes_pushpull (Src);
610+
611+
// END-imagebufalgo-fillholes_pushpull
612+
Filled.write("checker_with_alpha_filled.exr");
613+
614+
}
615+
616+
617+
void example_median_filter()
618+
{
619+
print("example_median_filter\n");
620+
// BEGIN-imagebufalgo-median_filter
621+
ImageBuf Noisy ("tahoe.tif");
622+
ImageBuf Clean = ImageBufAlgo::median_filter (Noisy, 3, 3);
623+
// END-imagebufalgo-median_filter
624+
Clean.write("tahoe_median_filter.tif");
625+
626+
}
627+
628+
629+
void example_unsharp_mask()
630+
{
631+
print("example_unsharp_mask\n");
632+
// BEGIN-imagebufalgo-unsharp_mask
633+
ImageBuf Blurry ("tahoe.tif");
634+
ImageBuf Sharp = ImageBufAlgo::unsharp_mask (Blurry, "gaussian", 5.0f);
635+
// END-imagebufalgo-unsharp_mask
636+
Sharp.write("tahoe_unsharp_mask.tif");
637+
638+
}
639+
586640

587641
// Section: Morphological filters
588642

@@ -664,6 +718,11 @@ int main(int /*argc*/, char** /*argv*/)
664718

665719
// Section: Image enhancement / restoration
666720

721+
example_fixNonFinite();
722+
example_fillholes_pushpull();
723+
example_median_filter();
724+
example_unsharp_mask();
725+
667726
// Section: Morphological filters
668727

669728
// Section: Color space conversion

testsuite/docs-examples-python/ref/out.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ example_absdiff
3434
example_abs
3535
example_mul
3636
example_div
37+
example_fixNonFinite
38+
example_fillholes_pushpull
39+
example_median_filter
40+
example_unsharp_mask
3741
example_make_texture
3842
zero1.exr : 512 x 512, 3 channel, half openexr
3943
SHA-1: 95823C334FCE55968E8D2827CCD1CF77CEE19ABD
@@ -127,6 +131,12 @@ mul.exr : 256 x 256, 4 channel, half openexr
127131
SHA-1: ECCDBBBF088912F0B77B887D6B8B480C3F93615E
128132
div.exr : 256 x 256, 4 channel, half openexr
129133
SHA-1: 6A85C923DB82C893C0D88028386F1C58604A4757
134+
checker_with_alpha_filled.exr : 256 x 256, 4 channel, half openexr
135+
SHA-1: B245E027638D5C1BA2608FEDDB3BB9B5E9FA3A44
136+
tahoe_median_filter.tif : 512 x 384, 3 channel, uint8 tiff
137+
SHA-1: A0B2E3A10A16EA8CC905F144C5F91B6A0964A177
138+
tahoe_unsharp_mask.tif : 512 x 384, 3 channel, uint8 tiff
139+
SHA-1: D3B56074F48EC5D3ADDA4BDE1F487192ABE9BA76
130140
Comparing "simple.tif" and "../docs-examples-cpp/ref/simple.tif"
131141
PASS
132142
Comparing "scanlines.tif" and "../docs-examples-cpp/ref/scanlines.tif"

testsuite/docs-examples-python/run.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
command += run_app("cmake -E copy " + test_source_dir + "/../common/tahoe-small.tif tahoe.tif")
1616
command += run_app("cmake -E copy " + test_source_dir + "/../common/grid-small.exr A.exr")
1717
command += run_app("cmake -E copy " + test_source_dir + "/../common/grid-small.exr B.exr")
18+
command += run_app("cmake -E copy " + test_source_dir + "/../common/with_nans.tif with_nans.tif")
19+
command += run_app("cmake -E copy " + test_source_dir + "/../common/checker_with_alpha.exr checker_with_alpha.exr")
1820

1921
# Copy the grid to both a tiled and scanline version
2022
command += oiio_app("iconvert") + "../common/grid.tif --scanline scanline.tif > out.txt ;"
@@ -77,8 +79,10 @@
7779
"absdiff.exr",
7880
"abs.exr",
7981
"mul.exr",
80-
"div.exr"
81-
82+
"div.exr",
83+
"checker_with_alpha_filled.exr",
84+
"tahoe_median_filter.tif",
85+
"tahoe_unsharp_mask.tif"
8286
]
8387
for file in hashes :
8488
command += info_command(file, verbose=False)

testsuite/docs-examples-python/src/docs-examples-imagebufalgo.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,41 @@ def example_div():
512512

513513
# Section: Image enhancement / restoration
514514

515+
def example_fixNonFinite():
516+
print("example_fixNonFinite")
517+
# BEGIN-imagebufalgo-fixNonFinite
518+
Src = ImageBuf("with_nans.tif")
519+
ImageBufAlgo.fixNonFinite (Src, Src, oiio.NONFINITE_BOX3)
520+
# END-imagebufalgo-fixNonFinite
521+
522+
# fixing the nans seems nondeterministic - so not writing out the image
523+
# Src.write("with_nans_fixed.tif")
524+
525+
def example_fillholes_pushpull():
526+
print("example_fillholes_pushpull")
527+
# BEGIN-imagebufalgo-fillholes_pushpull
528+
Src = ImageBuf("checker_with_alpha.exr")
529+
Filled = ImageBufAlgo.fillholes_pushpull(Src)
530+
# END-imagebufalgo-fillholes_pushpull
531+
Filled.write("checker_with_alpha_filled.exr")
532+
533+
534+
def example_median_filter():
535+
print("example_median_filter")
536+
# BEGIN-imagebufalgo-median_filter
537+
Noisy = ImageBuf("tahoe.tif")
538+
Clean = ImageBufAlgo.median_filter (Noisy, 3, 3)
539+
# END-imagebufalgo-median_filter
540+
Clean.write("tahoe_median_filter.tif")
541+
542+
543+
def example_unsharp_mask():
544+
print("example_unsharp_mask")
545+
# BEGIN-imagebufalgo-unsharp_mask
546+
Blurry = ImageBuf("tahoe.tif")
547+
Sharp = ImageBufAlgo.unsharp_mask (Blurry, "gaussian", 5.0)
548+
# END-imagebufalgo-unsharp_mask
549+
Sharp.write("tahoe_unsharp_mask.tif")
515550

516551
# Section: Morphological filters
517552

@@ -589,6 +624,10 @@ def example_make_texture():
589624
# Section: Convolution and frequency-space algorithms
590625

591626
# Section: Image enhancement / restoration
627+
example_fixNonFinite()
628+
example_fillholes_pushpull()
629+
example_median_filter()
630+
example_unsharp_mask()
592631

593632
# Section: Morphological filters
594633

0 commit comments

Comments
 (0)