Questions tagged [bilinear-interpolation]

89 questions
42
votes
8 answers

Inverse Bilinear Interpolation?

I have four 2d points, p0 = (x0,y0), p1 = (x1,y1), etc. that form a quadrilateral. In my case, the quad is not rectangular, but it should at least be convex. p2 --- p3 | | t | p | | | p0 --- p1 s I'm using bilinear…
tfinniga
  • 6,693
  • 3
  • 32
  • 37
26
votes
11 answers

Inverting a real-valued index grid

OpenCV's remap() uses a real-valued index grid to sample a grid of values from an image using bilinear interpolation, and returns the grid of samples as a new image. To be precise, let: A = an image X = a grid of real-valued X coords into the…
SuperElectric
  • 17,548
  • 10
  • 52
  • 69
18
votes
2 answers

tf.image.resize_bilinear vs cv2.resize

The results from tf.image.resize_bilinear are quite different from cv2.resize. I found this a little bothersome. Set align_corners=True is not always reasonable because the four corners are not always supposed to be fixed in the corner. So is there…
LI Xuhong
  • 2,339
  • 2
  • 17
  • 32
12
votes
3 answers

OpenCV resize() result is wrong?

Sample program that upscales 2x2 matrix to 5x5 using bilinear interpolation. Result that OpenCV produces has artifacts at the borders for such simple case. gy, gx = np.mgrid[0:2, 0:2] gx = np.float32(gx) print(gx) res = cv2.resize(gx,(5,5), fx=0,…
olegkhr
  • 374
  • 3
  • 8
9
votes
4 answers

Select PHP's Image resizing algorithm

The function imagecopyresampled is useful to generate a thumbnail or resize images, while keeping aspect ratio: $fn = $_FILES['data']['tmp_name']; $size = getimagesize($fn); $width = $size[0]; $height = $size[1]; $ratio = $width / $height; if…
Basj
  • 41,386
  • 99
  • 383
  • 673
8
votes
2 answers

Is this possible to create 2-axis 4 color gradient in css (bilinear gradient)?

My exmaple in JavaScript and . https://codepen.io/KonradLinkowski/pen/QWbjaPr const canvas = document.querySelector('#box') const ctx = canvas.getContext('2d') const interpolate = (value, start, end) => (end - start) * value +…
8
votes
1 answer

MATLAB pcolor/surf bilinear interpolation (shading interp)

Consider the following MATLAB code: C = [ 0 0 0 0 0 0 1 2 1 0 0 2 4 2 0 0 1 2 1 0 0 0 0 0 0 ]; pcolor( C ); shading interp; axis square Note that C is invariant under 90 degree rotations. Also note this sentence from the…
cfp
  • 208
  • 1
  • 7
6
votes
0 answers

Character recognition from an image C++

*Note: while this post is pretty much asking about bilinear interpolation I kept the title more general and included extra information in case someone has any ideas on how I can possibly do this better I have been having trouble implementing a way…
5
votes
1 answer

tf.image.resize_bilinear()-when align_corners=False

I am using Tensorflow 1.4.0 The Tensorflow tf.image.resize_bilinear() has an argument called 'align_corners' and I am confused with the behavior when we set it to be False. In the official document, it says: align_corners: An optional bool.…
Depu
  • 51
  • 1
  • 3
4
votes
1 answer

Obtain function from akima::interp() matrix

Using the interp function (Akima package), it is possible to draw the surface corresponding to the bivariate interpolation of a data set, see example below (from interp documentation): library(rgl) data(akima) # data…
JohnBee
  • 1,720
  • 1
  • 15
  • 19
3
votes
1 answer

Why is my bilinear interpolation vastly different from the in-built matlab function?

I've been working on bilinear interpolation based on wiki example in matlab. I followed the example to the T, but when comparing the outputs from my function and the in-built matlab function, the results are vastly different and I can't figure out…
Vocaloidas
  • 360
  • 2
  • 17
3
votes
1 answer

2D linear interpolation in R

I want to do a bilinear interpolation in R but I cant figure out how to do it with akima interp function because I get a matrix half fill with numbers and half with NA. This is an example of my problem: x = rep(c(1,2,3,6,9,12)/12,5) y =…
Alejandro Andrade
  • 2,196
  • 21
  • 40
3
votes
2 answers

How to interpolate between n colors by a fractional contribution for each color?

How can I interpolate between n colors. Simple case of 2 colors Consider a more simple case first, where we want to find the mid-point of 2 colors. Color1 is RGB ( 255, 0, 0 ) // Red Color2 is RGB ( 128, 128, 128 ) // Grey The solution being the…
3
votes
1 answer

how to understand caffe's bilinear upsampling

caffe'doc says that: layer { name: "upsample", type: "Deconvolution" bottom: "{{bottom_name}}" top: "{{top_name}}" convolution_param { kernel_size: {{2 * factor - factor % 2}} stride: {{factor}} num_output: {{C}} group: {{C}} pad:…
wang
  • 55
  • 1
  • 11
2
votes
1 answer

What is the difference between torch.nn.functional.grid_sample and torch.nn.functional.interpolate?

Let's say I have an image I want to downsample to half its resolution via either grid_sample or interpolate from the torch.nn.functional library. I select mode ='bilinear' for both cases. For grid_sample, I'd do the following: dh =…
1
2 3 4 5 6