How to use morphological open operation on a [B,C,H,W] tensor in the testing state?]

Hi, everyone.
In the testing stage, I need to use morphological operations like open operation for image post-processing. Is there any ready-made libraries? Could anyone give me some suggestions? Thanks a lot!