Manuscript Offprint

arXiv:2610.32203

Neural Disjunctive Normal Forms for Learning Exact Rank Filters

Diego Marcondes, Wonder A. L. Alves, Ronaldo F. Hashimoto

Diego Marcondes 1^{1} ID^{ID}, Wonder A. L. Alves 2^{2} ID^{ID}, and Ronaldo F. Hashimoto 3^{3} ID^{ID}

1^{1} Mathematical Sciences Institute and France-Australia Mathematical Sciences and Interactions ANU-CNRS International Research Lab, The Australian National University

2^{2} PPGI, Universidade Nove de Julho, São Paulo, Brazil

3^{3} IME, Universidade de São Paulo, São Paulo, Brazil

Abstract. Gradient-based learning of morphological operators is hindered by locally sparse derivatives with respect to the structuring elements. We develop a method for learning rank filters that retains exact operator evaluation while distributing the derivatives across the window. Using threshold decomposition, we construct a neural disjunctive normal form representation and establish a sufficient condition for exactness with integer-valued images and structuring elements. We then derive a smooth surrogate from the unique root of a smooth threshold equation. Implicit differentiation gives closed-form derivatives with normalised local weights, whose distribution is controlled by a smoothing parameter. These derivatives are used in a straight-through procedure: the forward pass evaluates the exact rank filter, while the backward pass uses the surrogate. For fixed ranks, the procedure learns real-valued structuring elements of any rank filter, including the median, and extends to compositions, infima, and suprema of rank filters. Experiments on image denoising using MNIST and Fashion-MNIST and retinal vessel segmentation show that, starting from a generic random initialisation, the proposed approach consistently improves performance over training with exact subgradients in every setting. In image denoising, our best network also outperforms smooth morphological networks in all settings. On vessel segmentation, the learned erosions recover structuring elements that fit the vessels, as theoretically expected, whereas most of those trained with exact subgradients remain close to their initialisation.

Keywords: Mathematical morphology · Morphological neural networks · Rank filters · Neural disjunctive normal form · Straight-through estimator

1 Introduction

Rank filters, including erosions and dilations, describe image transformations through local order statistics and structuring elements [12]. Learning the structuring elements from paired images adapts these transformations to a task, and the resulting operator is determined by its window, rank, and structuring element. Preserving exact evaluation keeps this description valid throughout training and inference. However, at each pixel where the selected order statistic is attained at a unique position, the derivative with respect to the structuring element is nonzero only at that position. This local gradient sparsity can hinder optimisation and make training sensitive to initialisation [3,6,7].

D. Marcondes et al.

Morphological networks have been trained with the exact operators and their sub-gradient [8], which inherits this sparsity. Recent works keep this setting and address it through guidelines on initialisation and learning rates [3], and, for a single supremum of erosions, through data-driven initialisations and denser descent updates [6,7]. Alternatively, smooth layers can replace the operators by differentiable approximations [4,10], so that the trained operator only approximates a morphological one. As a compromise, older alternatives keep the exact operator in the forward pass and modify only its derivative. Salembier [16] adapted rank filters through an implicit formulation of the rank by sign functions, and Pessoa and Maragos [15] replaced the rank indicator vector by smoothed impulses that spread the gradient over the window. This smoothing is a heuristic design choice rather than the derivative of a function representing the filter.

In this paper, we rely on the threshold decomposition [12,17] of rank filters to represent them as a sum, over thresholds, of order statistics of Boolean variables, and adapt the semi-symbolic layer of pix2rule [5] to obtain a neural disjunctive normal form representation of these order statistics, which yields a smooth representation of rank filters that is exact on the integer grid when the smoothing parameter is large enough. Implicit differentiation of the root of a smooth threshold equation yields a surrogate derivative with normalised weights over the window which have the form of the smoothed impulses of Pessoa and Maragos [15]. However, unlike their heuristic approach, our weights are obtained as the exact derivatives of a mathematically defined smooth surrogate of the filter, addressing gradient sparsity in a principled way.

For fixed ranks, we use these derivatives in a straight-through procedure [2] that learns real-valued structuring elements: the forward pass evaluates the exact filter, while the backward pass uses the surrogate. The smoothing parameter controls the distribution of the local derivative across the window, while the evaluated filter remains exact and independent of that choice. The procedure applies to any rank, such as the median, which smooth layers do not usually cover, and to compositions, infima and suprema of rank filters. It thus, in principle, extends to grey-level images the framework of discrete morphological neural networks [13], which learn exact binary operators combined by composition, infimum and supremum in architectures designed from prior knowledge.

We evaluate the procedure on image denoising and retinal vessel segmentation, comparing it with direct differentiation (subgradient) of exact operators and, for denoising, with smooth morphological networks. These comparisons assess whether redistributing the derivatives improves learning while retaining exact operator evaluation. Starting from a generic random initialisation, not tailored to the data, our method consistently improves on the exact subgradient in every setting, without requiring the specialised initialisation strategies employed by recent exact-training approaches [3,6,7] and our best network outperforms the smooth networks in all denoising settings, while the trained operator remains exact. Moreover, just as the layers of discrete morphological neural networks specialise into the expected steps of a task, such as denoising followed by boundary extraction, without being constrained to do so [14], the erosions learned by our method for retinal vessels recover structuring elements of different sizes and orientations that fit into the vessels, as theoretically expected [19], whereas most of those learned with the exact subgradient remain close to their random initialisation.

Our main contributions are therefore: (i) a theoretically grounded approximation of rank-filter derivatives, rather than a heuristic redistribution of gradients [15]; (ii) exact forward evaluation combined with smoother backward gradients, mitigating the dependence on specialised initialisation strategies of recent exact-training methods [3,6,7]; and (iii) the demonstration of effective training on non-trivial image processing tasks, starting from generic random initialisations, improving upon exact-subgradient training and smooth morphological layers.

References (19)