Algorithm 1:
For i=1 to (Width-1)
For j=1 to (Height -1)
Set(i,j)th pixel as White Color;
For i=1 to (Width-1)
For j=1 to (Height -1)
{
diff:=Abs( Difference between Red component of (i, j)th and (i+1, j+1)th pixel )
+ Abs( Difference between Green component of (i, j)th and (i+1, j+1)th pixel)
+ Abs( Difference between Blue component of (i, j)th and (i+1, j+1)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
diff:=Abs( Difference between Red component of (i, j)th and (i+1, j-1)th pixel)
+ Abs( Difference between Green component of (i, j)th and (i+1, j-1)th pixel)
+ Abs( Difference between Blue component of (i, j)th and (i+1, j-1)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
diff:=Abs( Difference between Red component of (i, j)th and (i-1, j-1)th pixel )
+ Abs( Difference between Green component of (i, j)th and (i-1, j-1)th pixel)
+ Abs( Difference between Blue component of (i, j)th and (i-1, j-1)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
diff:=Abs( Difference between Red component of (i, j)th and (i-1, j+1)th pixel )
+ Abs( Difference between Green component of (i, j)th and (i-1, j+1)th pixel)
+ Abs( Difference between Blue component of (i, j)th and (i-1, j+1)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
diff:=Abs( Difference between Red component of (i, j)th and (i+1, j)th pixel)
+ Abs( Difference between Green component of (i, j)th and (i+1, j)th pixel)
+ Abs( Difference between Blue component of (i, j)th and (i+1, j)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
diff:=Abs( Difference between Red component of (i, j)th and (i, j-1)th pixel)
+ Abs( Difference between Green component of (i, j)th and (i, j-1)th pixel)
+ Abs( Difference between Blue component of (i, j)th and (i, j-1)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
diff:=Abs( Difference between Red component of (i, j)th and (i-1, j)th pixel )
+ Abs( Difference between Green component of (i, j)th and (i-1, j)th pixel)
+ Abs( Difference between Blue component of (i, j)th and (i-1, j)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
diff:=Abs( Difference between Red component of (i, j)th and (i, j+1)th pixel )
+ Abs( Difference between Green component of (i, j)th and (i, j+1)th pixel)
+ Abs( Difference between Blue component of (i, j)th and (i, j+1)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
}
Algorithm 2:
For i=1 to (Width-1)
For j=1 to (Height -1)
Set(i,j)th pixel as White Color;
For i=1 to (Width-1)
For j=1 to (Height -1)
{
diff:=Abs( Difference between Red component of (i, j)th and (i+1, j+1)th pixel )
+ Abs( Difference between Blue component of (i, j)th and (i+1, j+1)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
diff:=Abs( Difference between Red component of (i, j)th and (i-1, j+1)th pixel )
+ Abs( Difference between Blue component of (i, j)th and (i-1, j+1)th pixel);
IF diff > threshold
Set (i,j)th pixel as Black Color;
Continue;
End IF
}