I am currently doing a project where I have to halftoning printing by ordered dithering . However, after doing my dithering processing, my image showing in this way . Does anyone know what I'm doing wrong?
Image dithering(Image input, int orderedDithering[2][2])
{
Image output = input ;
int x , y ;
for( x=0 ; x < input.height ; x++)
{
int i = x % 4 ;
for( y=0; y<input.width; y++)
{
int j = y % 4 ;
#define R(X,Y) input.term[(Y)*input.rowsize+3*(X)+2]
#define G(X,Y) input.term[(Y)*input.rowsize+3*(X)+1]
#define B(X,Y) input.term[(Y)*input.rowsize+3*(X)]
input.term[(y)*input.rowsize+3*(x)+2] = (R(x,y) < orderedDithering[i][j] ? 0 : 255);
input.term[(y)*input.rowsize+3*(x)+1] = (G(x,y) < orderedDithering[i][j] ? 0 : 255);
input.term[(y)*input.rowsize+3*(x)+0] = (B(x,y) < orderedDithering[i][j] ? 0 : 255);
}
}
return output ;
}