Image enlargement draws a smaller image on a larger blank image. This section describes the principle of mosaic Effect and Its Simulation.
It can be seen that the image enlargement of the mosaic effect is the enlargement of the original pixel.
Simulation Algorithm:
C #: Class Program
{
Static Void Main ( String [] ARGs)
{
Int [,] = New Int [,] { 1 , 2 , 3 , 4 },{ 5 , 6 , 7 , 8 }};
Print (enlarge (,4));
}
Static Int [,] Enlarge ( Int [,] SRC, Int Zoom)
{
If (Zoom < 1 )
{
Throw New Indexoutofrangeexception ( " The magnification cannot be less than 1. " );
}
If (zoom = 1 )
{< br> return SRC;
}
Int[,] DST= New Int[SRC. getlength (0)*Zoom, SRC. getlength (1)*Zoom];
For ( Int I = 0 ; I < DST. getlength ( 0 ); I ++ )
{
For ( Int J = 0 ; J < DST. getlength ( 1 ); J ++ )
{
DST [I, j] = SRC [(I / Zoom) % (Zoom * Zoom), (J / Zoom) % (Zoom * Zoom)];
}
}
ReturnDST;
}
Static Void Print ( Int [,] Array)
{
For ( Int I = 0 ; I < Array. getlength ( 0 ); I ++ )
{
Console. writeline ( "" );
For ( Int J = 0 ; J < Array. getlength ( 1 ); J ++ )
{
Console. Write ( " " + Array [I, j]);
}
}
}
}
to achieve more realistic image amplification, the original image can be filled with excessive colors of two adjacent pixels after being enlarged, that is, interpolation algorithm , which involves quadratic interpolation and multiple interpolation. Its essence can be the besell curve algorithm or other approximate algorithms. If there is no special algorithm optimization for image enlargement, the generated image will inevitably become blurred or mosaic.