Skip to main content
added a reference
Source Link
Laurent Duval
  • 32.3k
  • 3
  • 35
  • 105

The median filter can be applied on many pixel-set shapes, and indeed this was used to emulate of fasten full 2D median filters by a combination of leaner medians.

median filter shapes

In Matlab, your request just amounts to gather diagonal elements in a vector. The simplest could be:

  • extract each sliding square patch of the image
  • extract the diagonal as a matrix with diag.m
  • compute the median

If you want the antidiagonal, flip the square patch with flipud, fliprl. If you want other diagonals than the $\pm 45°$, you have to use discrete lines, for instance with the Bresenham algorithm.

If you want to remain high level, I'd suggest you to use gblk: a pedestrian data block extractor at MatlabCentral to parse an image with overlapping blocks.

The median filter can be applied on many pixel-set shapes, and indeed this was used to emulate of fasten full 2D median filters by a combination of leaner medians.

median filter shapes

In Matlab, your request just amounts to gather diagonal elements in a vector. The simplest could be:

  • extract each sliding square patch of the image
  • extract the diagonal as a matrix with diag.m
  • compute the median

If you want the antidiagonal, flip the square patch with flipud, fliprl. If you want other diagonals than the $\pm 45°$, you have to use discrete lines, for instance with the Bresenham algorithm.

The median filter can be applied on many pixel-set shapes, and indeed this was used to emulate of fasten full 2D median filters by a combination of leaner medians.

median filter shapes

In Matlab, your request just amounts to gather diagonal elements in a vector. The simplest could be:

  • extract each sliding square patch of the image
  • extract the diagonal as a matrix with diag.m
  • compute the median

If you want the antidiagonal, flip the square patch with flipud, fliprl. If you want other diagonals than the $\pm 45°$, you have to use discrete lines, for instance with the Bresenham algorithm.

If you want to remain high level, I'd suggest you to use gblk: a pedestrian data block extractor at MatlabCentral to parse an image with overlapping blocks.

Source Link
Laurent Duval
  • 32.3k
  • 3
  • 35
  • 105

The median filter can be applied on many pixel-set shapes, and indeed this was used to emulate of fasten full 2D median filters by a combination of leaner medians.

median filter shapes

In Matlab, your request just amounts to gather diagonal elements in a vector. The simplest could be:

  • extract each sliding square patch of the image
  • extract the diagonal as a matrix with diag.m
  • compute the median

If you want the antidiagonal, flip the square patch with flipud, fliprl. If you want other diagonals than the $\pm 45°$, you have to use discrete lines, for instance with the Bresenham algorithm.