interpolation

How Bicubic-interpolation work?

After reading text about this said topic, i found out that it considers 16 of the original neighboring pixels. What i want to know is how does it compute the color value of the new pixel. If the color of pixels can be determined by 200,100,255, how could you compute the value of the new one? ...

How can I escape meta-characters when I interpolate a variable in Perl's match operator?

Suppose I have a file containing lines I'm trying to match against: foo quux bar In my code, I have another array: foo baz quux Let's say we iterate through the file, calling each element $word, and the internal list we are checking against, @arr. if( grep {$_ =~ m/^$word$/i} @arr) This works correctly, but in the somewhat possi...

Fuzzy Top Edge with GDIPlus Resize

I'm using the following code to resize a bitmap using GDI+ in C. I'm getting gray values for the top edge even for images where that area should be white. The problem disappears when the interpolation is nearest neighbor. However, I tried bicubic interpolation with ImageMagick and it seems fine. Any limitations problems I should know of...

What's the difference between single and double quotes in Perl?

I am just begining to learn Perl. I looked at the beginning perl page and started working. It says: The difference between single quotes and double quotes is that single quotes mean that their contents should be taken literally, while double quotes mean that their contents should be interpreted When I run this program: #!/usr/l...

iphone like button flow

I'm really impressed with the way the iPhone manages scrolling lists (such as through play lists). I was wondering how I could impelment something similar and what I should read up on before trying to? I'm more interested in the mathematics behind the motion, the interpolation and such rather than implementing it for any given system. ...

How do you escape Ruby string interpolation?

Given this code: has_many :foos, :finder_sql = <<-SQL select * from foos where bars = #{id} SQL The #{id} part is being prematurely interpolated. How do I escape it? Thanks. ...

Math question in regards to functions in the form (1) / ( b ^ c )

I've found functions which follow the pattern of 1 / bc produce nice curves which can be coupled with interpolation functions really nicely. The way I use the function is by treating 'c' as the changing value, i.e. the interpolation value between 0 and 1, while varying b for 'sharpness'. I use it to work out an interpolation value betwe...

Flex LineSeries interpolateValues as ZERO?

In a LineChart in Flex you can set a LineSeries to interpolateValues="true" what this does is connect missing values so you do not have gaps in your line. But what I would like is for it to insert 0's for the missing fields instead of drawing a direct line to fill the gap. Is there a way to set it to do that? Thanks!! ...

machine precision

Hi, I wonder if there is something like eps to represent the value of machine precision in C++? Can I use it as the smallest positive number that a double can represent? Is it possible to use 1.0/eps as the max positive number that a double can represent? Where can I find eps in both C++ and C standard libraries? Thanks and regards! ...

inverse distance weighting interpolation

I would like to compute a weight as reciprocal of a distance for something like inverse distance weighting interpolation (http://en.wikipedia.org/wiki/Inverse_distance_weighting). double wgt = 0, wgt_tmp, result = 0; for (int i = 0; i < num; i++) { wgt_tmp = 1.0/dist[i]; wgt += wgt_tmp; result += wgt_tmp * values[i]; } results ...

Is there any way to specify a generic argument to a function with the restriction that it should implement a given interface

Example: I have a function that works with vectors: double interpolate2d(const vector<double> & xvals, const vector<double> & yvals, double xv, double yv, const vector<vector<double> > &fvals) { int xhi, xlo, yhi, ylo; double xphi, yphi; bracketval(xvals,xv,xhi,xlo,xphi); bracketval(yvals,yv,yhi,ylo,yphi); return (f...

How can I include a variable in a Perl printf expression?

How can I include a variable in a printf expression? Here's my example: printf "%${cols}s", $_; Where $cols is the number of columns and $_ is a string. The statement results in an "Invalid conversion" warning. The problem ended up being that I forgot to chomp the variable. Gah. Thanks everyone. ...

Interpolating 2d data that is piecewise constant on faces

I have an irregular mesh which is described by two variables - a faces array that stores the indices of the vertices that constitute each face, and a verts array that stores the coordinates of each vertex. I also have a function that is assumed to be piecewise constant over each face, and it is stored in the form of an array of values pe...

How to improve performance when interpolating on 3d data with SciPy

Hello there, I have 3d-data representing the atmosphere. Now I want to interpolate this data to a common Z coordinate (what I mean by that should be clear from the function's doctring). The following code works fine, but I was wondering if there were a way to improve the performance ... def interpLevel(grid,value,data,interp='linear'):...

Flex LineSeries - find y-value along curve

I've created a Flex LineChart that shows high and low tide predictions over time. I'm using the LineSeries with form="curve", which produces a nice sinusoidal wave graph, representing water level over time. The X-axis represents time, and the Y-axis represents water level. The only data points I have to work with are high and low tide v...

How to interpolate the coordinates of a vector on an image using MATLAB?

For instance, if I have got a vector describing a rectangle xy=[165 88; 401 88; 401 278; 165 278]; on an image. How can I obtain the following vector [165 88; % increase X - hold y 166 88; 167 88; ... ; 399 88; 400 88; 401 88; % hold x - increase y 401 89; 401 90; 401 91; ... ; 4...

Given an octree of voxels, how do you render with smooth surfaces?

I noticed most 3d voxel models are actually pretty low resolution, but then are rendered all smoothed out with some sort of interpolation. Given its ray traced, what is the algorithm used to render it smoothly? Could anybody suggest a book on the topic? ...

Polymorphic Paperclip overwriting files with the same names

Hi, in Rails using the Polymorphic version of Paperclip, the default saving technique means that files with the same name overwrite each other. Including the :id in the path and URL doesn't work as it just overwrites the earlier file with the old :id. I've tried interpolations using a time-stamp, but it just looks for the current time w...

Interpolating 1D Gaussian into 2D Gaussian

Let's say I have a 1D Gaussian function. Its length is 600 for that matter. I want to Interpolate it into 2D Gaussian of the size 600 X 600. This is the code I wrote (OTFx is the Gaussian Function, OTF - 2d Interpolated Function): [x, y] = meshgrid([-300:299], [-300:299]); r = sqrt((x .^ 2) + (y .^ 2)); OTF = interp1([-300:299], OTFx...

Algorithm for 2D Interpolation

I have two shapes which are cross sections of a channel. I want to calculate the cross section of an intermediate point between the two defined points. What's the simplest (relatively simple?) algorithm to use in this situation? P.S.: I came across several algorithms like natural neighbor and poisson, which seemed complex. I'm looking f...