Image enlargement algorithm (mosaic effect)

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.