function B = ordered_dither(I, D)
    x = size(I,1)/size(D,1);
    y = size(I,2)/size(D,2);
    B = repmat(D, x, y);
    
    I(B<I) = 1;
    I(B>=I) = 0;
    
    B = I;
end