Skip to content

Commit 3ebf0b8

Browse files
committed
fixNonFinite doc2test
Signed-off-by: Daniel Greenstein <[email protected]>
1 parent e45a625 commit 3ebf0b8

File tree

8 files changed

+52
-15
lines changed

8 files changed

+52
-15
lines changed

src/doc/imagebufalgo.rst

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,26 +2534,30 @@ Image Enhancement / Restoration
25342534
Result-as-parameter version:
25352535
.. doxygenfunction:: fixNonFinite(ImageBuf &dst, const ImageBuf &src, NonFiniteFixMode mode = NONFINITE_BOX3, int *pixelsFixed = nullptr, ROI roi = {}, int nthreads = 0)
25362536

2537+
25372538
Examples:
25382539

2539-
.. tabs::
2540-
2541-
.. code-tab:: c++
2540+
.. tabs::
25422541

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

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

2551-
Src = ImageBuf("tahoe.exr")
2552-
ImageBufAlgo.fixNonFinite (Src, Src, "box3", oiio.NONFINITE_BOX3)
2556+
.. tab:: oiiotool
2557+
.. sourcecode:: bash
25532558

2554-
.. code-tab:: bash oiiotool
2559+
oiiotool with_nans.tif --fixnan box3 -o with_nans_fixed.tif
25552560

2556-
oiiotool tahoe.exr --fixnan box3 -o fixed.exr
25572561

25582562
|
25592563

testsuite/common/with_nans.tif

536 KB
Binary file not shown.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ example_resize
2727
example_resample
2828
example_fit
2929
example_warp
30+
example_fixNonFinite
31+
Repaired 48 non-finite pixels
3032
example_make_texture
3133
zero1.exr : 512 x 512, 3 channel, half openexr
3234
SHA-1: 95823C334FCE55968E8D2827CCD1CF77CEE19ABD
@@ -106,6 +108,8 @@ cshift.exr : 256 x 256, 4 channel, half openexr
106108
SHA-1: 000F95FDC44D4DBDA8B4041C2506149C7AE28ACA
107109
texture.exr : 256 x 256, 3 channel, half openexr (+mipmap)
108110
SHA-1: 4074B050432CE7C664CEC4546A46E74F9A310CDC
111+
with_nans_fixed.tif : 256 x 256, 3 channel, float tiff
112+
SHA-1: FE830FB041FAE5F1AA16B23FB69B91DED4BF5B73
109113
Comparing "simple.tif" and "ref/simple.tif"
110114
PASS
111115
Comparing "scanlines.tif" and "ref/scanlines.tif"

testsuite/docs-examples-cpp/run.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# Prep:
1414
command += run_app("cmake -E copy " + test_source_dir + "/../common/grid-small.exr grid.exr")
1515
command += run_app("cmake -E copy " + test_source_dir + "/../common/tahoe-small.tif tahoe.tif")
16+
command += run_app("cmake -E copy " + test_source_dir + "/../common/with_nans.tif with_nans.tif")
1617

1718
# Build
1819
command += run_app("cmake -S " + test_source_dir + " -B build -DCMAKE_BUILD_TYPE=Release >> build.txt 2>&1", silent=True)
@@ -68,7 +69,8 @@
6869
"transpose.exr",
6970
"reorient.exr",
7071
"cshift.exr",
71-
"texture.exr"
72+
"texture.exr",
73+
"with_nans_fixed.tif"
7274
]
7375
for file in hashes :
7476
command += info_command(file, verbose=False)

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,19 @@ void example_warp()
504504

505505
// Section: Image enhancement / restoration
506506

507+
void example_fixNonFinite()
508+
{
509+
print("example_fixNonFinite\n");
510+
// BEGIN-imagebufalgo-fixNonFinite
511+
ImageBuf Src ("with_nans.tif");
512+
int pixelsFixed = 0;
513+
ImageBufAlgo::fixNonFinite (Src, Src, ImageBufAlgo::NONFINITE_BOX3,
514+
&pixelsFixed);
515+
std::cout << "Repaired " << pixelsFixed << " non-finite pixels\n";
516+
// END-imagebufalgo-fixNonFinite
517+
Src.write("with_nans_fixed.tif");
507518

519+
}
508520
// Section: Morphological filters
509521

510522

@@ -579,6 +591,8 @@ int main(int /*argc*/, char** /*argv*/)
579591

580592
// Section: Image enhancement / restoration
581593

594+
example_fixNonFinite();
595+
582596
// Section: Morphological filters
583597

584598
// Section: Color space conversion

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ example_resize
2828
example_resample
2929
example_fit
3030
example_warp
31+
example_fixNonFinite
3132
example_make_texture
3233
zero1.exr : 512 x 512, 3 channel, half openexr
3334
SHA-1: 95823C334FCE55968E8D2827CCD1CF77CEE19ABD
@@ -107,6 +108,8 @@ cshift.exr : 256 x 256, 4 channel, half openexr
107108
SHA-1: 000F95FDC44D4DBDA8B4041C2506149C7AE28ACA
108109
texture.exr : 256 x 256, 3 channel, half openexr (+mipmap)
109110
SHA-1: 4074B050432CE7C664CEC4546A46E74F9A310CDC
111+
with_nans_fixed.tif : 256 x 256, 3 channel, float tiff
112+
SHA-1: FE830FB041FAE5F1AA16B23FB69B91DED4BF5B73
110113
Comparing "simple.tif" and "../docs-examples-cpp/ref/simple.tif"
111114
PASS
112115
Comparing "scanlines.tif" and "../docs-examples-cpp/ref/scanlines.tif"

testsuite/docs-examples-python/run.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# Prep:
1414
command += run_app("cmake -E copy " + test_source_dir + "/../common/grid-small.exr grid.exr")
1515
command += run_app("cmake -E copy " + test_source_dir + "/../common/tahoe-small.tif tahoe.tif")
16+
command += run_app("cmake -E copy " + test_source_dir + "/../common/with_nans.tif with_nans.tif")
1617

1718
# Run the examples for each chapter
1819
for chapter in [ "imageioapi", "imageoutput", "imageinput", "writingplugins",
@@ -64,8 +65,10 @@
6465
"transpose.exr",
6566
"reorient.exr",
6667
"cshift.exr",
67-
"texture.exr"
68+
"texture.exr",
69+
"with_nans_fixed.tif"
6870
]
71+
6972
for file in hashes :
7073
command += info_command(file, verbose=False)
7174

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,12 @@ def example_warp():
446446

447447
# Section: Image enhancement / restoration
448448

449+
def example_fixNonFinite():
450+
print("example_fixNonFinite")
451+
Src = ImageBuf("with_nans.tif")
452+
ImageBufAlgo.fixNonFinite (Src, Src, oiio.NONFINITE_BOX3)
453+
Src.write("with_nans_fixed.tif")
454+
449455

450456
# Section: Morphological filters
451457

@@ -517,6 +523,7 @@ def example_make_texture():
517523
# Section: Convolution and frequency-space algorithms
518524

519525
# Section: Image enhancement / restoration
526+
example_fixNonFinite()
520527

521528
# Section: Morphological filters
522529

0 commit comments

Comments
 (0)