Illustration of block-matching and 3D-filtering algorithm. The BM3D algorithm is demonstrated using a STEM image of a gallium nitride crystal as an example. The magenta/cyan squares resemble exemplary 16×16 reference blocks (two out of 58,081 possible ones in the 256×256 image). The red/blue squares mark blocks that were matched to the magenta/cyan reference. The matched noisy blocks are stacked into 3D tensors (top right), which is then denoised, e.g., by replacing all pixels with mean values along the column direction (indicated by the black-dotted arrow). The resulting denoised blocks (bottom right) are then aggregated at their original positions within the image (bottom left image), and overlapping parts (green) of adjacent blocks are averaged, yielding a single denoised image as the result.