MATLAB: Can any body have ordered dithering code by bayer’s method for 2*2 and 4*4

ditheringhalftoning

ordered dithering is to halftone the image. by applying threshold through a matrix.
Related Question