Connected filters are edge-preserving morphological operators, which rely on a notion of connectivity. This is usually the standard 4 and 8-connectivity, which is often too rigid since it cannot model generalized groupings such as object clusters or partitions. In the set-theoretical framework of connectivity, these groupings are modeled by the more general second-generation connectivity. In this paper, we present both an extension of this theory, and provide an efficient algorithm based on the Max-Tree to compute attribute filters based on these connectivities. We first look into the drawbacks of the existing framework that separates clustering and partitioning and is directly dependent on the properties of a preselected operator. We then ...