0

So I am working on a project which resizes images in Matlab, however, I have decided to not use the in-built functions, but rather understand how this is done mathematically.

So far I have a decent idea of how to scale the dimensions and re-allocate the existing pixels values in the new image.

My problem is finding out the values for the new pixels which do not yet have a colour value. In matlab the colours range from 0-255.

This is a very basic and dimmed-down version of the issue I am facing.

Current Image example:

   25 25
   25 25

New Image example:

  0 0  0 0  0
  0 25 0 25 0
  0 0  0 0  0
  0 25 0 25 0
  0 0  0 0  0

I am trying to find out what the value for the 0s would be.

I have searched the internet for this, and even tried to watch YouTube videos, but I haven't been able to find a solution for this.

If someone could give a slight insight into the maths behind this process, it would be very much appreciated.

Sans_P
  • 1

1 Answers1

1

The maths is secondary, this is a common Image Processing problem. The very nature of resizing an image means introducing more information than the original image had, and therefore there is no singular best way of doing it. It depends on the application, and how much computation you want to do. A few approaches are listed below, but they are not the only ones

  1. Nearest Neighbour - basically use the value in the nearest neighbour to populate the new cells. This usually produces very blocky aesthetics and is usually used in things like pixel art

  2. Linear interpolation - if you have a new point between two original points, you use a linear equation to interpolate between the two values, giving a smooth blend between the two. This is great for colour approximation, but usually blurs out sharp objects like lines and edges

  3. Bilinear interpolation - if linear interpolation is along one axis, bilinear is using data from four points to approximate all the points in the middle - to get a smooth colour and detail gradient. Similar problems to linear interpolation, but more symmetric

There are higher order approaches you can take as well to interpolate, but the crux is that each of these has a drawback - either they are simple but lose some detail, or they are complex and time-consuming, but capture more subtleties of the original image. I'd recommend looking up image interpolation and exploring for yourself