Skip to content

C program to quickly perform nearest neighbour image scaling to upscale 24bit or 32bit PNG images. Upscale functions should work with any image format if you can extract the values of each pixel in the image into a u_char array.

License

Notifications You must be signed in to change notification settings

cole8888/Nearest-Neighbour-Upscale

Repository files navigation

Nearest-Neighbor-Upscale

C program to quickly perform nearest neighbour upscaling of an image. Example driver code works on 24bit or 32bit PNG images. Upscaler functions should work with any image format if you can extract the values of each pixel in the image into a u_char array.

To use the example driver code:

  • git clone https://github.com/cole8888/Nearest-Neighbour-Upscale
  • cd Nearest-Neighbour-Upscale
  • make
  • ./NearestNeighbourUpscale <INPUT_IMAGE.PNG> <SCALE>
    • Where <INPUT_IMAGE.PNG> is the image you want to upscale and <SCALE> the the scale you want to upscale it by.

How it works:

For this example we will take this 25x25px image and upscale it to 50x50px.

(Please note I've upscaled the images in this demo by 10x so that they can easily be viewed without zooming in.)

upscaled_img79

  • Step 1: Copy the pixels from the original image into the top left corner of each expanded pixel 0624

  • Step 2: Fill in the top row of each expanded pixel with the data from the topleft-most pixel in that expanded pixel. 1249

  • Step 3: Fill in the remaining rows of each expanded pixel with the top row of each expanded pixel. 2499

(See the VIDEO_DEMOS directory if you'd like a visual representation.)

The example driver code uses lodepng which can be found here https://github.com/lvandeve/lodepng

About

C program to quickly perform nearest neighbour image scaling to upscale 24bit or 32bit PNG images. Upscale functions should work with any image format if you can extract the values of each pixel in the image into a u_char array.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published