From 0c69fcf6fa5657dc4aacd2ef4ede3895df8714d8 Mon Sep 17 00:00:00 2001 From: Julien-Haudegond <44610840+Julien-Haudegond@users.noreply.github.com> Date: Mon, 29 Jun 2020 13:02:34 +0200 Subject: [PATCH 01/10] [nodes] ImageProcessing: add metadata input folder --- meshroom/nodes/aliceVision/ImageProcessing.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index 28c706b9fd..d5c8028531 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -35,6 +35,18 @@ class ImageProcessing(desc.CommandLineNode): label="Images input Folders", description='Use images from specific folder(s).', ), + desc.ListAttribute( + elementDesc=desc.File( + name="metadataFolder", + label="Metadata Folder", + description="", + value="", + uid=[0], + ), + name="metadataFolders", + label="Metadata input Folders", + description='Use images metadata from specific folder(s).', + ), desc.ChoiceParam( name='extension', label='Output File Extension', From ea72cefa59cb78ccef08adebc6def2d50fb45afc Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Mon, 29 Jun 2020 13:21:19 +0200 Subject: [PATCH 02/10] [nodes] imageProcessing: add a checkbox for the Sharpen Filter --- meshroom/nodes/aliceVision/ImageProcessing.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index d5c8028531..2e84d5baa7 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -25,8 +25,8 @@ class ImageProcessing(desc.CommandLineNode): ), desc.ListAttribute( elementDesc=desc.File( - name="imagesFolder", - label="Images Folder", + name="inputFolder", + label="input Folder", description="", value="", uid=[0], @@ -101,11 +101,18 @@ class ImageProcessing(desc.CommandLineNode): value=False, uid=[0], ), + desc.BoolParam( + name='sharpen', + label='Sharpen', + description='Use sharpen.', + value=False, + uid=[0], + ), desc.IntParam( name='sharpenWidth', label='Sharpen Width', description='Sharpen Width.', - value=1, + value=3, range=(1, 9, 2), uid=[0], ), From fc55a64151b279c55c13c5272033876de8c31086 Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Mon, 29 Jun 2020 14:15:57 +0200 Subject: [PATCH 03/10] [nodes] ImageProcessing: use advanced StringParams for metadataFolders --- meshroom/nodes/aliceVision/ImageProcessing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index 2e84d5baa7..e83c09d6df 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -36,7 +36,7 @@ class ImageProcessing(desc.CommandLineNode): description='Use images from specific folder(s).', ), desc.ListAttribute( - elementDesc=desc.File( + elementDesc=desc.StringParam( name="metadataFolder", label="Metadata Folder", description="", @@ -46,6 +46,7 @@ class ImageProcessing(desc.CommandLineNode): name="metadataFolders", label="Metadata input Folders", description='Use images metadata from specific folder(s).', + advanced=True, ), desc.ChoiceParam( name='extension', From d9279feef9d5c5453bd375383281d3945d7977d6 Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Mon, 29 Jun 2020 14:30:28 +0200 Subject: [PATCH 04/10] [nodes] imageProcessing: group and rename filters params --- meshroom/nodes/aliceVision/ImageProcessing.py | 176 +++++++++--------- 1 file changed, 91 insertions(+), 85 deletions(-) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index e83c09d6df..e6e792580d 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -102,91 +102,97 @@ class ImageProcessing(desc.CommandLineNode): value=False, uid=[0], ), - desc.BoolParam( - name='sharpen', - label='Sharpen', - description='Use sharpen.', - value=False, - uid=[0], - ), - desc.IntParam( - name='sharpenWidth', - label='Sharpen Width', - description='Sharpen Width.', - value=3, - range=(1, 9, 2), - uid=[0], - ), - desc.FloatParam( - name='sharpenContrast', - label='Sharpen Contrast', - description='Sharpen Contrast.', - value=1.0, - range=(0.0, 100.0, 0.1), - uid=[0], - ), - desc.FloatParam( - name='sharpenThreshold', - label='Sharpen Threshold', - description='Sharpen Threshold.', - value=0.0, - range=(0.0, 1.0, 0.01), - uid=[0], - ), - desc.BoolParam( - name='bilateralFilter', - label='Bilateral Filter', - description='Bilateral Filter.', - value=False, - uid=[0], - ), - desc.IntParam( - name='bilateralFilterDistance', - label='Bilateral Filter Distance', - description='Diameter of each pixel neighborhood that is used during bilateral filtering.\nCould be very slow for large filters, so it is recommended to use 5.', - value=0, - range=(0, 9, 1), - uid=[0], - ), - desc.FloatParam( - name='bilateralFilterSigmaSpace', - label='Bilateral Filter Sigma Space', - description='Bilateral Filter sigma in the coordinate space.', - value=0.0, - range=(0.0, 150.0, 0.01), - uid=[0], - ), - desc.FloatParam( - name='bilateralFilterSigmaColor', - label='Bilateral Filter Sigma Color Space', - description='Bilateral Filter sigma in the color space.', - value=0.0, - range=(0.0, 150.0, 0.01), - uid=[0], - ), - desc.BoolParam( - name='claheFilter', - label='Clahe Filter', - description='Use Contrast Limited Adaptive Histogram Equalization (CLAHE) Filter.', - value=False, - uid=[0], - ), - desc.FloatParam( - name='claheClipLimit', - label='Clahe Clip Limit.', - description='Sets Threshold For Contrast Limiting.', - value=4.0, - range=(0.0, 8.0, 1.0), - uid=[0], - ), - desc.IntParam( - name='claheTileGridSize', - label='Clahe Tile Grid Size.', - description='Sets Size Of Grid For Histogram Equalization. Input Image Will Be Divided Into Equally Sized Rectangular Tiles.', - value=8, - range=(4, 64, 4), - uid=[0], - ), + desc.GroupAttribute(name="sharpenFilter", label="Sharpen Filter", description="Sharpen Filtering Parameters.", joinChar=":", groupDesc=[ + desc.BoolParam( + name='enabled', + label='Enable', + description='Use sharpen.', + value=False, + uid=[0], + ), + desc.IntParam( + name='width', + label='Width', + description='Sharpen Width.', + value=3, + range=(1, 9, 2), + uid=[0], + ), + desc.FloatParam( + name='contrast', + label='Contrast', + description='Sharpen Contrast.', + value=1.0, + range=(0.0, 100.0, 0.1), + uid=[0], + ), + desc.FloatParam( + name='threshold', + label='Threshold', + description='Sharpen Threshold.', + value=0.0, + range=(0.0, 1.0, 0.01), + uid=[0], + ), + ]), + desc.GroupAttribute(name="bilateralFilter", label="Bilateral Filter", description="Bilateral Filtering Parameters.", joinChar=":", groupDesc=[ + desc.BoolParam( + name='bilateralFilterEnabled', + label='Enable', + description='Bilateral Filter.', + value=False, + uid=[0], + ), + desc.IntParam( + name='bilateralFilterDistance', + label='Distance', + description='Diameter of each pixel neighborhood that is used during bilateral filtering.\nCould be very slow for large filters, so it is recommended to use 5.', + value=0, + range=(0, 9, 1), + uid=[0], + ), + desc.FloatParam( + name='bilateralFilterSigmaSpace', + label='Sigma Coordinate Space', + description='Bilateral Filter sigma in the coordinate space.', + value=0.0, + range=(0.0, 150.0, 0.01), + uid=[0], + ), + desc.FloatParam( + name='bilateralFilterSigmaColor', + label='Sigma Color Space', + description='Bilateral Filter sigma in the color space.', + value=0.0, + range=(0.0, 150.0, 0.01), + uid=[0], + ), + ]), + desc.GroupAttribute(name="claheFilter", label="Clahe Filter", description="Clahe Filtering Parameters.", joinChar=":", groupDesc=[ + desc.BoolParam( + name='claheEnabled', + label='Enable', + description='Use Contrast Limited Adaptive Histogram Equalization (CLAHE) Filter.', + value=False, + uid=[0], + ), + desc.FloatParam( + name='claheClipLimit', + label='Clip Limit.', + description='Sets Threshold For Contrast Limiting.', + value=4.0, + range=(0.0, 8.0, 1.0), + uid=[0], + ), + desc.IntParam( + name='claheTileGridSize', + label='Tile Grid Size.', + description='Sets Size Of Grid For Histogram Equalization. Input Image Will Be Divided Into Equally Sized Rectangular Tiles.', + value=8, + range=(4, 64, 4), + uid=[0], + ), + ]), desc.ChoiceParam( name='verboseLevel', label='Verbose Level', From dcc41a6a7adae1636601b642d45612b806c6c49b Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Wed, 1 Jul 2020 12:02:08 +0200 Subject: [PATCH 05/10] [nodes] imageProcessing: Add Noise Filtering option --- meshroom/nodes/aliceVision/ImageProcessing.py | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index e6e792580d..90316037a6 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -178,7 +178,7 @@ class ImageProcessing(desc.CommandLineNode): ), desc.FloatParam( name='claheClipLimit', - label='Clip Limit.', + label='Clip Limit', description='Sets Threshold For Contrast Limiting.', value=4.0, range=(0.0, 8.0, 1.0), @@ -186,13 +186,57 @@ class ImageProcessing(desc.CommandLineNode): ), desc.IntParam( name='claheTileGridSize', - label='Tile Grid Size.', + label='Tile Grid Size', description='Sets Size Of Grid For Histogram Equalization. Input Image Will Be Divided Into Equally Sized Rectangular Tiles.', value=8, range=(4, 64, 4), uid=[0], ), ]), + desc.GroupAttribute(name="noiseFilter", label="Noise Filter", description="Noise Filtering Parameters.", joinChar=":", groupDesc=[ + desc.BoolParam( + name='noiseEnabled', + label='Enable', + description='Add Noise.', + value=False, + uid=[0], + ), + desc.ChoiceParam( + name='noiseMethod', + label='Method', + description=" * method: There are several noise types to choose from:\n" + " * uniform: adds noise values uninformly distributed on range [A,B).\n" + " * gaussian: adds Gaussian (normal distribution) noise values with mean value A and standard deviation B.\n" + " * salt: changes to value A a portion of pixels given by B.\n", + value='uniform', + values=['uniform', 'gaussian', 'salt'], + exclusive=True, + uid=[0], + ), + desc.FloatParam( + name='noiseA', + label='A', + description='Parameter that have a different interpretation depending on the method chosen.', + value=0.0, + range=(0.0, 1.0, 0.0001), + uid=[0], + ), + desc.FloatParam( + name='noiseB', + label='B', + description='Parameter that have a different interpretation depending on the method chosen.', + value=1.0, + range=(0.0, 1.0, 0.0001), + uid=[0], + ), + desc.BoolParam( + name='noiseMono', + label='Mono', + description='If is Checked, a single noise value will be applied to all channels otherwise a separate noise value will be computed for each channel.', + value=True, + uid=[0], + ), + ]), desc.ChoiceParam( name='verboseLevel', label='Verbose Level', From fadb1b472f318e10ecb75b49d551e9802e7c5543 Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Thu, 2 Jul 2020 17:02:26 +0200 Subject: [PATCH 06/10] [nodes] imageProcessing: output format option Allows you to choose the output format (RGBA, RGB, Grayscale) --- meshroom/nodes/aliceVision/ImageProcessing.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index 90316037a6..8f3feba1b6 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -237,6 +237,16 @@ class ImageProcessing(desc.CommandLineNode): uid=[0], ), ]), + desc.ChoiceParam( + name='outputFormat', + label='Output Image Format', + description='Allows you to choose the format of the output image.', + value='rgba', + values=['rgba', 'rgb', 'grayscale'], + exclusive=True, + advanced=True, + uid=[0], + ), desc.ChoiceParam( name='verboseLevel', label='Verbose Level', From 67a87a5f09d7ffda7543a8b5f25af1d19941ac57 Mon Sep 17 00:00:00 2001 From: Enguerrand DE SMET Date: Fri, 17 Jul 2020 10:49:14 +0200 Subject: [PATCH 07/10] [nodes] imageProcessing: fix outputImages value --- meshroom/nodes/aliceVision/ImageProcessing.py | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index 8f3feba1b6..ffc60e258d 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -4,7 +4,24 @@ import os.path - +def outputImagesValueFunct(attr): + basename = os.path.basename(attr.node.input.value) + fileStem = os.path.splitext(basename)[0] + inputExt = os.path.splitext(basename)[1] + outputExt = ('.' + attr.node.extension.value) if attr.node.extension.value else None + + if inputExt in ['.abc', '.sfm']: + return desc.Node.internalFolder + '*' + (outputExt or '.*') + elif inputExt : + return desc.Node.internalFolder + fileStem + (outputExt or inputExt) + else: + if '*' in fileStem: + # Assume the input fileStem is a regular expression to files + return desc.Node.internalFolder + fileStem + (outputExt or '.*') + else: + # No extension mean it is a folder path + return desc.Node.internalFolder + fileStem + '/' + (outputExt or '.*') + class ImageProcessing(desc.CommandLineNode): commandLine = 'aliceVision_utils_imageProcessing {allParams}' size = desc.DynamicNodeSize('input') @@ -278,8 +295,9 @@ class ImageProcessing(desc.CommandLineNode): name='outputImages', label='Output Images', description='Output Image Files.', - value=lambda attr: desc.Node.internalFolder + os.path.basename(attr.node.input.value) if (os.path.splitext(attr.node.input.value)[1] not in ['', '.abc', '.sfm']) else (desc.Node.internalFolder + '*.' + (attr.node.extension.value or '*')), + # value=lambda attr: desc.Node.internalFolder + os.path.splitext(attr.node.input.value)[0] + (('.' + attr.node.extension.value) if attr.node.extension.value else os.path.splitext(attr.node.input.value)[1]) if (os.path.splitext(attr.node.input.value)[1] not in ['', '.abc', '.sfm']) else (desc.Node.internalFolder + '*.' + (attr.node.extension.value or '*')), + value= outputImagesValueFunct, group='', # do not export on the command line uid=[], ), - ] + ] \ No newline at end of file From 6888322adc4356da99d3bc0b5e7a8020ab7488ff Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Sat, 18 Jul 2020 13:52:34 +0200 Subject: [PATCH 08/10] [nodes] ImageProcessing: bug fix and minor code simplification --- meshroom/nodes/aliceVision/ImageProcessing.py | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index ffc60e258d..43d4f3fcb5 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -9,19 +9,25 @@ def outputImagesValueFunct(attr): fileStem = os.path.splitext(basename)[0] inputExt = os.path.splitext(basename)[1] outputExt = ('.' + attr.node.extension.value) if attr.node.extension.value else None - + if inputExt in ['.abc', '.sfm']: + # If we have an SfM in input return desc.Node.internalFolder + '*' + (outputExt or '.*') - elif inputExt : + + if inputExt: + # if we have one or multiple files in input return desc.Node.internalFolder + fileStem + (outputExt or inputExt) - else: - if '*' in fileStem: - # Assume the input fileStem is a regular expression to files - return desc.Node.internalFolder + fileStem + (outputExt or '.*') - else: - # No extension mean it is a folder path - return desc.Node.internalFolder + fileStem + '/' + (outputExt or '.*') - + + if '*' in fileStem: + # The fileStem of the input param is a regular expression, + # so even if there is no file extension, + # we consider that the expression represents files. + return desc.Node.internalFolder + fileStem + (outputExt or '.*') + + # No extension and no expression means that the input param is a folder path + return desc.Node.internalFolder + '*' + (outputExt or '.*') + + class ImageProcessing(desc.CommandLineNode): commandLine = 'aliceVision_utils_imageProcessing {allParams}' size = desc.DynamicNodeSize('input') From bf278e4eb098ea46b0233f3abb79506341c488c8 Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Sat, 18 Jul 2020 13:53:43 +0200 Subject: [PATCH 09/10] [nodes] ImageProcessing: remove useless comment --- meshroom/nodes/aliceVision/ImageProcessing.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index 43d4f3fcb5..e1b1a68070 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -301,9 +301,8 @@ class ImageProcessing(desc.CommandLineNode): name='outputImages', label='Output Images', description='Output Image Files.', - # value=lambda attr: desc.Node.internalFolder + os.path.splitext(attr.node.input.value)[0] + (('.' + attr.node.extension.value) if attr.node.extension.value else os.path.splitext(attr.node.input.value)[1]) if (os.path.splitext(attr.node.input.value)[1] not in ['', '.abc', '.sfm']) else (desc.Node.internalFolder + '*.' + (attr.node.extension.value or '*')), value= outputImagesValueFunct, group='', # do not export on the command line uid=[], ), - ] \ No newline at end of file + ] From 40c35faf489e039f6b2e6d2329212386a75bfc55 Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Sat, 18 Jul 2020 13:57:08 +0200 Subject: [PATCH 10/10] [nodes] ImageProcessing: change advanced status --- meshroom/nodes/aliceVision/ImageProcessing.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index e1b1a68070..fda72c712a 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -69,7 +69,6 @@ class ImageProcessing(desc.CommandLineNode): name="metadataFolders", label="Metadata input Folders", description='Use images metadata from specific folder(s).', - advanced=True, ), desc.ChoiceParam( name='extension', @@ -267,9 +266,8 @@ class ImageProcessing(desc.CommandLineNode): value='rgba', values=['rgba', 'rgb', 'grayscale'], exclusive=True, - advanced=True, uid=[0], - ), + ), desc.ChoiceParam( name='verboseLevel', label='Verbose Level',