0

If in digital image processing, i use bilinear interpolation for image scaling and if the scaling factor is 1.5x then how do i represent 1.5th column in a physical matrix structure?

  • If you're asking what matrix you use to calculate the interpolation, then it depends on which pixel of the output you're generating. A 1.5x scale will repeat every 3 pixels, but if the scaling ratio is not easily divisible then each matrix could be unique across the entire image. – Mark Ransom Feb 08 '18 at 23:23
  • Could you please clarify your question? I don't understand what it is that you have trouble with (and nobody else does either, this is why there are no answers yet). Maybe add some explanation about what you think is bilinear interpolation, or include some code with how you think it would be computed. – Cris Luengo Feb 09 '18 at 01:58
  • Sorry for trouble sir. According to the definition of the book i tried to imaging 500*500 into 750*750 grid.But the problem is i am not understanding inorder to generate new pixel column/row , after how many old column/row i should generate a new column or row? – Satyaki Chatterjee Feb 09 '18 at 02:07

1 Answers1

3

This is a quick sketch of how interpolation works:

Assume you are going from an image of size NxN to an image of size MxM.

Step 1: Create an intermediate image of size MxN. The 2nd dimension stays the same for now. We interpolate only along the first dimension.

So for each image line, the input is N values, and we generate M values. Assume the coordinates of the input values are 0, 1, 2, 3, ... N-1. The coordinates for the output values will be 0, N/M, 2*N/M, ... N-1. This gives you fractional coordinates.

For each output value, interpolate the input values. For example, the 4th output value is at 3*N/M. Pick out input values at locations floor(3*N/M) and ceil(3*N/M), and compute your linearly interpolated values.

Step 2: Create the output image of size M*M, and repeat the process above for each line along the 2nd dimension, again growing from N samples to M samples.

If the 1D interpolation is a separate function, this process is really easy to implement. Many people will implement bilinear interpolation directly as a 2D operation, computing the 2D coordinates for each output value. But implementing it as a separable transformation has many benefits. For example, it makes it easy to change the interpolation method to cubic, Lanczos, or even b-splines, because it's all 1D. It is also easy to extend the process from 2D images to 3D images.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
  • But for input image N*N and intermediate image M*N how will we generate M column for the output image – Satyaki Chatterjee Feb 09 '18 at 11:57
  • That's explained there. You find each of the M values in each image line by interpolation from the corresponding input image line. – Cris Luengo Feb 09 '18 at 15:36
  • @SatyakiChatterjee : please edit your question and post some code for how you think you'd implement this. That way I can see where your mental block is. Fill in the parts you know, and add comments for the part you don't know how to do. – Cris Luengo Feb 09 '18 at 15:48
  • Sir,i have almost resolved my confusion.Only one thing which i am not understanding should i apply interpolation on RGB or ARGB or R,G,B invidually? – Satyaki Chatterjee Feb 10 '18 at 17:58
  • @SatyakiChatterjee apply it individually to each channel. – Cris Luengo Feb 10 '18 at 18:53
  • Thank you sir.But once i implement this few yellow dots are appearing on the image?Is this noise? – Satyaki Chatterjee Feb 10 '18 at 20:04
  • Actually the approach i have taken is- – Satyaki Chatterjee Feb 10 '18 at 20:14
  • Actually the approach i have taken is- for each cell i figured out the 4 diagonal neighbour then i have separated the Red green and blue value .Then all the red values from four neighbour goes through the following formula: Ax +By+ Cxy+D where A,B,C,D are the four red values from 4 neighbour and x,y being the cell for which we are interpolating.Same goes for green and blue. Then the red intensity , green intensity and blue intensity are gathered together to produce rgb intensity of the output image's x,y cell.Is this a wrong approach? – Satyaki Chatterjee Feb 10 '18 at 20:22
  • If `x` and `y` are the fractional components of the coordinate (pos-round(pos)), then you need to multiply values to the left with `1-x`, values to the right with `x`, values to the top with `1-y` and values to the bottom with `y`. – Cris Luengo Feb 10 '18 at 20:53
  • It's a weighted average, with the 1-distance to the values as the weights. – Cris Luengo Feb 10 '18 at 20:54
  • Sir i have implemented the way you said,still this is giving an image with the physical grid visible allover the image..is that noise? – Satyaki Chatterjee Feb 11 '18 at 08:48