diff --git a/backend/src/packages/chaiNNer_standard/__init__.py b/backend/src/packages/chaiNNer_standard/__init__.py index 3317539b3..3d6e20277 100644 --- a/backend/src/packages/chaiNNer_standard/__init__.py +++ b/backend/src/packages/chaiNNer_standard/__init__.py @@ -77,7 +77,7 @@ Dependency( display_name="ChaiNNer Extensions", pypi_name="chainner_ext", - version="0.3.9", + version="0.3.10", size_estimate=2.0 * MB, ), ], diff --git a/backend/src/packages/chaiNNer_standard/image_adjustment/threshold/threshold.py b/backend/src/packages/chaiNNer_standard/image_adjustment/threshold/threshold.py index aff00ebb5..153351f2f 100644 --- a/backend/src/packages/chaiNNer_standard/image_adjustment/threshold/threshold.py +++ b/backend/src/packages/chaiNNer_standard/image_adjustment/threshold/threshold.py @@ -62,9 +62,19 @@ class ThresholdType(Enum): controls_step=1, ).with_id(2), ), - BoolInput("Anti-aliasing", default=False).with_docs( + BoolInput("Anti-aliasing", default=False) + .with_docs( "Enables sub-pixel precision. Bilinear interpolation is used to fill in values in between pixels.", "Conceptually, the option is equivalent to first upscaling the image by a factor of X (with linear interpolation), thresholding it, and then downscaling it by a factor of X (where X is 20 or more).", + ) + .with_id(4), + if_enum_group(4, 1)( + SliderInput("Softness", default=0, minimum=0, maximum=10) + .with_docs( + "The strength of a sub-pixel blur applied to be anti-aliased image. This can be be used to make the anti-aliasing even softer.", + "The blur is very small and higher-quality than a simple Gaussian blur. 0 means that no additional blur will be applied. 10 means that the anti-aliasing will be very soft.", + ) + .with_id(5), ), ], outputs=[ @@ -82,15 +92,17 @@ def threshold_node( thresh_type: ThresholdType, max_value: float, anti_aliasing: bool, + extra_smoothness: float, ) -> np.ndarray: threshold /= 100 max_value /= 100 + extra_smoothness /= 10 if not anti_aliasing: _, result = cv2.threshold(img, threshold, max_value, thresh_type.value) return result - binary = binary_threshold(img, threshold, True) + binary = binary_threshold(img, threshold, True, extra_smoothness) if get_h_w_c(binary)[2] == 1: binary = as_2d_grayscale(binary)