views:

54

answers:

3

I'm reading a paper that talks about using a lerp function in image synthesis. What exactly is a lerp and how would you synthesize an image using one if you are given two images as inputs?

+1  A: 

'lerp'ing is just a way to guestimate an intermediary value. For example, if one value was 10, and the next was 8, a 'lerp' function might return 9. There's several ways to make the estimation - linear, trigonomic, etc. At its simplest, linear, you're just taking (distance from value 1 * value 1) + (distance from value 2 * value 2) where distance ranges from 0 to 1.

In image processing, this is done with the color values between pixels. If you are zooming in past 100%, for example, you'd use a lerp function to determine what to draw in the areas that represent partial pixels.

I should add, I looked at that article, and it references Perlin noise. In that type of algorithm, lerp'ing functions are used quite extensively to calculate values in between points where data exists that can be passed into the perlin or fractal algoritm to generate a value for that intermediary point.

GrandmasterB
A: 

How would you synthesize it? By using the function. The function would give you the output for given inputs at any pixel. Interpolating two images doesn't make any sense though, you're probably interested in using interpolation for resizing. It also has some interesting properties. A sinc interpolator is equivalent to running the image through a brick wall low-pass filter in Frequency space.

For two images, your function would perform some sort of addition or averaging, whatever you're interested in. If you're synthesizing something, interpolation is equivalent to running it through a low pass filter. For instance, if two images are sampled at different rates and you want to put one on top of the other, you'd want to interpolate the lower rate over the higher rate sampled image.

Gary
A: 

What exactly is a lerp and

lerp(factor, a, b) = factor*a + (1.0 - factor)*b

where factor is in range [0, 1.0]

See wikipedia

how would you synthesize an image using one if you are given two images as inputs?

You need two source images (src1, src2) and destination image (dst) of equal size. Plus interpolation factor.

Then for every pixel do (RGB color):

dst[x][y].r = lerp(factor, src1[x][y].r, src2[x][y].r)
dst[x][y].g = lerp(factor, src1[x][y].g, src2[x][y].g)
dst[x][y].b = lerp(factor, src1[x][y].b, src2[x][y].b)
SigTerm