Skip to content

Implement some operators for boolean matrices #832

Open
@mpizenberg

Description

@mpizenberg

Today I wanted to do some logical operations on matrices of booleans. Ideally, it would be as simple as calling m1 | m2 & m3 for example. My concrete use case is building the union of masks and I'm currently doing the following (with some additional asserts on sizes):

/// Merge multiple sparse matrices into one combining all sparsely selected pixels.
pub fn merge(matrices: &[DMatrix<bool>]) -> DMatrix<bool> {
    let mut merged = matrices[0].clone();
    for mat in matrices.iter().skip(1) {
        for (b_merged, b) in merged.iter_mut().zip(mat) {
            *b_merged |= b;
        }
    }
    merged
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneed community feedbackFeedbacks are needed from the community before implementing a solution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions