Search Results

Search found 227 results on 10 pages for 'interpolation'.

Page 4/10 | < Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >

  • GSL interpolation error, values must be x values must be monotonically increasing

    - by pyCthon
    Hi my problem is that my data set is monotonically increasing but towards the end the of the data it looks like it does below ,where some of the x[i-1] = x[i] as shown below. This causes an error to be raised in GSL because it thinks that the values are not monotonically increasing. Is there a solution, fix or work around for this problem? the values are already double precision ,this particular data set starts at 9.86553e-06 and ends at .999999 would the only solution be to offset every value in a for loop? 0.999981 0.999981 0.999981 0.999982 0.999982 0.999983 0.999983 0.999983 0.999984 0.999984 0.999985 0.999985 0.999985

    Read the article

  • Interpolation on Cubism graphs

    - by Abe Stanway
    Cubism was designed, by mbostock's own words, for maximum information density - which means it generally wants to display one datapoint per pixel. While this is useful in many cases, it doesn't help when your data itself is not that dense. In these cases, you get ugly, staccato-style graphs like so: Is there a way to interpolate my data/graph within Cubism to show a nice, smoothed graph? EDIT: After adding keepLastValue to the metric, I get this: Here is the same data as shown in Graphite: I would like to smooth the Cubism view to look more like Graphite (with the added awesomeness of the horizon overplotting)

    Read the article

  • Linear color interpolation?

    - by user146780
    If I have a straight line that mesures from 0 to 1, then I have colorA(255,0,0) at 0 on the line, then at 0.3 I have colorB(20,160,0) then at 1 on the line I have colorC(0,0,0). How could I find the color at 0.7? Thanks

    Read the article

  • How to interpolate hue values in HSV colour space?

    - by nick
    Hi, I'm trying to interpolate between two colours in HSV colour space to produce a smooth colour gradient. I'm using a linear interpolation, eg: h = (1 - p) * h1 + p * h2 s = (1 - p) * s1 + p * s2 v = (1 - p) * v1 + p * v2 (where p is the percentage, and h1, h2, s1, s2, v1, v2 are the hue, saturation and value components of the two colours) This produces a good result for s and v but not for h. As the hue component is an angle, the calculation needs to work out the shortest distance between h1 and h2 and then do the interpolation in the right direction (either clockwise or anti-clockwise). What formula or algorithm should I use? EDIT: By following Jack's suggestions I modified my JavaScript gradient function and it works well. For anyone interested, here's what I ended up with: // create gradient from yellow to red to black with 100 steps var gradient = hsbGradient(100, [{h:0.14, s:0.5, b:1}, {h:0, s:1, b:1}, {h:0, s:1, b:0}]); function hsbGradient(steps, colours) { var parts = colours.length - 1; var gradient = new Array(steps); var gradientIndex = 0; var partSteps = Math.floor(steps / parts); var remainder = steps - (partSteps * parts); for (var col = 0; col < parts; col++) { // get colours var c1 = colours[col], c2 = colours[col + 1]; // determine clockwise and counter-clockwise distance between hues var distCCW = (c1.h >= c2.h) ? c1.h - c2.h : 1 + c1.h - c2.h; distCW = (c1.h >= c2.h) ? 1 + c2.h - c1.h : c2.h - c1.h; // ensure we get the right number of steps by adding remainder to final part if (col == parts - 1) partSteps += remainder; // make gradient for this part for (var step = 0; step < partSteps; step ++) { var p = step / partSteps; // interpolate h var h = (distCW <= distCCW) ? c1.h + (distCW * p) : c1.h - (distCCW * p); if (h < 0) h = 1 + h; if (h > 1) h = h - 1; // interpolate s, b var s = (1 - p) * c1.s + p * c2.s; var b = (1 - p) * c1.b + p * c2.b; // add to gradient array gradient[gradientIndex] = {h:h, s:s, b:b}; gradientIndex ++; } } return gradient; }

    Read the article

  • Can I interpolate two HEX color values without converting them to RGB?

    - by navand
    I'm trying to make a Gradient Class for a Blackberry app. At first I thought about converting the HEX values to RGB and then interpolating them before converting the result back into HEX, but since I will be doing this for every pixel line of an area, and the calculations will be made by a mobile, I thought that maybe there's a more efficient way of doing it. Maybe involving those pesky bitwise operators which I know nothing of... or something. So, is there a way of interpolating without converting to RGB and back? If so, is it faster than the original way? In any case, can you help me make the most efficient color interpolation? Thank you in advance!

    Read the article

  • What's the most effective way to interpolate between two colors? (pseudocode and bitwise ops expecte

    - by navand
    Making a Blackberry app, want a Gradient class. What's the most effective way (as in, speed and battery life) to interpolate two colors? Please be specific. // Java, of course int c1 = 0xFFAA0055 // color 1, ARGB int c2 = 0xFF00CCFF // color 2, ARGB float st = 0 // the current step in the interpolation, between 0 and 1 /* Help from here on. Should I separate each channel of each color, convert them to decimal and interpolate? Is there a simpler way? interpolatedChannel = red1+((red2-red1)*st) interpolatedChannel = interpolatedChannel.toString(16) ^ Is this the right thing to do? If speed and effectiveness is important in a mobile app, should I use bitwise operations? Help me! */

    Read the article

  • Interpolating data points in Excel

    - by Niels Basjes
    Hi, I'm sure this is the kind of problem other have solved many times before. A group of people are going to do measurements (Home energy usage to be exact). All of them will do that at different times and in different intervals. So what I'll get from each person is a set of {date, value} pairs where there are dates missing in the set. What I need is a complete set of {date, value} pairs where for each date withing the range a value is known (either measured or calculated). I expect that a simple linear interpolation would suffice for this project. If I assume that it must be done in Excel. What is the best way to interpolate in such a dataset (so I have a value for every day) ? Thanks. NOTE: When these datasets are complete I'll determine the slope (i.e. usage per day) and from that we can start doing home-to-home comparisons. ADDITIONAL INFO After first few suggestions: I do not want to manually figure out where the holes are in my measurement set (too many incomplete measurement sets!!). I'm looking for something (existing) automatic to do that for me. So if my input is {2009-06-01, 10} {2009-06-03, 20} {2009-06-06, 110} Then I expect to automatically get {2009-06-01, 10} {2009-06-02, 15} {2009-06-03, 20} {2009-06-04, 50} {2009-06-05, 80} {2009-06-06, 110} Yes, I can write software that does this. I am just hoping that someone already has a "ready to run" software (Excel) feature for this (rather generic) problem.

    Read the article

  • Using scipy.interpolate.splrep function

    - by Koustav Ghosal
    I am trying to fit a cubic spline to a given set of points. My points are not ordered. I CANNOT sort or reorder the points, since I need that information. But since the function scipy.interpolate.splrep works only on non-duplicate and monotonically increasing points I have defined a function that maps the x-coordinates to a monotonically increasing space. My old points are: xpoints=[4913.0, 4912.0, 4914.0, 4913.0, 4913.0, 4913.0, 4914.0, 4915.0, 4918.0, 4921.0, 4925.0, 4932.0, 4938.0, 4945.0, 4950.0, 4954.0, 4955.0, 4957.0, 4956.0, 4953.0, 4949.0, 4943.0, 4933.0, 4921.0, 4911.0, 4898.0, 4886.0, 4874.0, 4865.0, 4858.0, 4853.0, 4849.0, 4848.0, 4849.0, 4851.0, 4858.0, 4864.0, 4869.0, 4877.0, 4884.0, 4893.0, 4903.0, 4913.0, 4923.0, 4935.0, 4947.0, 4959.0, 4970.0, 4981.0, 4991.0, 5000.0, 5005.0, 5010.0, 5015.0, 5019.0, 5020.0, 5021.0, 5023.0, 5025.0, 5027.0, 5027.0, 5028.0, 5028.0, 5030.0, 5031.0, 5033.0, 5035.0, 5037.0, 5040.0, 5043.0] ypoints=[10557.0, 10563.0, 10567.0, 10571.0, 10575.0, 10577.0, 10578.0, 10581.0, 10582.0, 10582.0, 10582.0, 10581.0, 10578.0, 10576.0, 10572.0, 10567.0, 10560.0, 10550.0, 10541.0, 10531.0, 10520.0, 10511.0, 10503.0, 10496.0, 10490.0, 10487.0, 10488.0, 10488.0, 10490.0, 10495.0, 10504.0, 10513.0, 10523.0, 10533.0, 10542.0, 10550.0, 10556.0, 10559.0, 10560.0, 10559.0, 10555.0, 10550.0, 10543.0, 10533.0, 10522.0, 10514.0, 10505.0, 10496.0, 10490.0, 10486.0, 10482.0, 10481.0, 10482.0, 10486.0, 10491.0, 10497.0, 10506.0, 10516.0, 10524.0, 10534.0, 10544.0, 10552.0, 10558.0, 10564.0, 10569.0, 10573.0, 10576.0, 10578.0, 10581.0, 10582.0] Plots: The code for the mapping function and interpolation is: xnew=[] ynew=ypoints for c3,i in enumerate(xpoints): if np.isfinite(np.log(i*pow(2,c3))): xnew.append(np.log(i*pow(2,c3))) else: if c==0: xnew.append(np.random.random_sample()) else: xnew.append(xnew[c3-1]+np.random.random_sample()) xnew=np.asarray(xnew) ynew=np.asarray(ynew) constant1=10.0 nknots=len(xnew)/constant1 idx_knots = (np.arange(1,len(xnew)-1,(len(xnew)-2)/np.double(nknots))).astype('int') knots = [xnew[i] for i in idx_knots] knots = np.asarray(knots) int_range=np.linspace(min(xnew),max(xnew),len(xnew)) tck = interpolate.splrep(xnew,ynew,k=3,task=-1,t=knots) y1= interpolate.splev(int_range,tck,der=0) The code is throwing an error at the function interpolate.splrep() for some set of points like the above one. The error is: File "/home/neeraj/Desktop/koustav/res/BOS5/fit_spline3.py", line 58, in save_spline_f tck = interpolate.splrep(xnew,ynew,k=3,task=-1,t=knots) File "/usr/lib/python2.7/dist-packages/scipy/interpolate/fitpack.py", line 465, in splrep raise _iermessier(_iermess[ier][0]) ValueError: Error on input data But for other set of points it works fine. For example for the following set of points. xpoints=[1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1629.0, 1630.0, 1630.0, 1630.0, 1631.0, 1631.0, 1631.0, 1631.0, 1630.0, 1629.0, 1629.0, 1629.0, 1628.0, 1627.0, 1627.0, 1625.0, 1624.0, 1624.0, 1623.0, 1620.0, 1618.0, 1617.0, 1616.0, 1615.0, 1614.0, 1614.0, 1612.0, 1612.0, 1612.0, 1611.0, 1610.0, 1609.0, 1608.0, 1607.0, 1607.0, 1603.0, 1602.0, 1602.0, 1601.0, 1601.0, 1600.0, 1599.0, 1598.0] ypoints=[10570.0, 10572.0, 10572.0, 10573.0, 10572.0, 10572.0, 10571.0, 10570.0, 10569.0, 10565.0, 10564.0, 10563.0, 10562.0, 10560.0, 10558.0, 10556.0, 10554.0, 10551.0, 10548.0, 10547.0, 10544.0, 10542.0, 10541.0, 10538.0, 10534.0, 10532.0, 10531.0, 10528.0, 10525.0, 10522.0, 10519.0, 10517.0, 10516.0, 10512.0, 10509.0, 10509.0, 10507.0, 10504.0, 10502.0, 10500.0, 10501.0, 10499.0, 10498.0, 10496.0, 10491.0, 10492.0, 10488.0, 10488.0, 10488.0, 10486.0, 10486.0, 10485.0, 10485.0, 10486.0, 10483.0, 10483.0, 10482.0, 10480.0] Plots: Can anybody suggest what's happening ?? Thanks in advance......

    Read the article

  • Interpolating Large Datasets On the Fly

    - by Karl
    Interpolating Large Datasets I have a large data set of about 0.5million records representing the exchange rate between the USD / GBP over the course of a given day. I have an application that wants to be able to graph this data or maybe a subset. For obvious reasons I do not want to plot 0.5 million points on my graph. What I need is a smaller data set (100 points or so) which accurately (as possible) represents the given data. Does anyone know of any interesting and performant ways this data can be achieved? Cheers, Karl

    Read the article

  • Interpolating 2d data that is piecewise constant on faces

    - by celil
    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 per face. I am looking for a way to construct a function f from this data. Something along the following lines: faces = [[0,1,2], [1,2,3], [2,3,4] ...] verts = [[0,0], [0,1], [1,0], [1,1],....] vals = [0.0, 1.0, 0.5, 3.0,....] f = interpolate(faces, verts, vals) f(0.2, 0.2) = 0.0 # point inside face [0,1,2] f(0.6, 0.6) = 1.0 # point inside face [1,2,3] The manual way of evaluating f(x,y) would be to find the corresponding face that the point x,y lies in, and return the value that is stored in that face. Is there a function that already implements this in scipy (or in matlab)?

    Read the article

  • Generate colors between red and green for a power meter?

    - by Simucal
    I'm writing a java game and I want to implement a power meter for how hard you are going to shoot something. I need to write a function that takes a int between 0 - 100, and based on how high that number is, it will return a color between Green (0 on the power scale) and Red (100 on the power scale). Similar to how volume controls work: What operation do I need to do on the Red, Green, and Blue components of a color to generate the colors between Green and Red? So, I could run say, getColor(80) and it will return an orangish color (its values in R, G, B) or getColor(10) which will return a more Green/Yellow rgb value. I know I need to increase components of the R, G, B values for a new color, but I don't know specifically what goes up or down as the colors shift from Green-Red. Progress: I ended up using HSV/HSB color space because I liked the gradiant better (no dark browns in the middle). The function I used was (in java): public Color getColor(double power) { double H = power * 0.4; // Hue (note 0.4 = Green, see huge chart below) double S = 0.9; // Saturation double B = 0.9; // Brightness return Color.getHSBColor((float)H, (float)S, (float)B); } Where "power" is a number between 0.0 and 1.0. 0.0 will return a bright red, 1.0 will return a bright green. Java Hue Chart: Thanks everyone for helping me with this!

    Read the article

  • How to get a flat, non-interpolated color when using vertex shaders.

    - by Brett
    Hi, Is there a way to achieve this? If I draw lines like this glShadeModel(GL_FLAT); glBegin(GL_LINES); glColor3f(1.0, 1.0, 0.0); glVertex3fv(bottomLeft); glVertex3fv(topRight); glColor3f(1.0, 0.0, 0.0); glVertex3fv(topRight); glVertex3fv(topLeft); . . (draw a square) . . glEnd(); I get the desired result (a different colour for each edge) but I want to be able to calculate the fragment values in a shader. If I do the same after setting up my shader program I always get interpolated colors between vertices. Is there a way around this? (would be even better if I could get the same results using quads) Thanks

    Read the article

  • How do I sum up weighted arrays in PHP?

    - by christian studer
    Hod do I multiply the values of a multi-dimensional array with weigths and sum up the results into a new array in PHP or in general? The boring way looks like this: $weights = array(0.25, 0.4, 0.2, 0.15); $values = array ( array(5,10,15), array(20,25,30), array(35,40,45), array(50,55,60) ); $result = array(); for($i = 0; $i < count($values[0]); ++$i) { $result[$i] = 0; foreach($weights as $index => $thisWeight) $result[$i] += $thisWeight * $values[$index][$i]; } Is there a more elegant solution?

    Read the article

  • How to make a simple grafical interface in C# for DCRAW

    - by Espinas.iss
    Hello, i have a problem. I need to make a simple GUI in Visual Studio 2008 using C Sharp that uses a Dave Coffins DCRAW written in C but I don't know how to "connect" dcraw.c (DCRAW source code) file with Csharp... UFRAW is the example of grafical interface that uses dcraw but I can't find it's source code. My application should be very simple: to recognize raw file on digital camera or any disc and uses one interpolatio algorithm on that raw file.

    Read the article

  • Fade a color to white (increasing brightness)

    - by Jon B
    I want to make a text box in .NET "glow" yellow, and then "fade" to white (basically, by incrementally increasing the brightness). I think Stackoverflow does this after you've posted an answer. I know that increasing brightness is not all that simple (it's not just uniformly increasing/decreasing RGB), but I'm not sure how to do this. Perfect color accuracy is not important for this. I am using C#, although VB examples would be just fine, too. Edit: This is for Winforms.

    Read the article

  • Interpolating 1D Gaussian into 2D Gaussian

    - by Drazick
    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, r(:), 'spline'); OTF = reshape(OTF, [600, 600]); The problem is I get Overshoot at the end: How can I prevent it? Is there better Interpolating algorithm for Monotonic Descending Functions?

    Read the article

  • extracting a quadrilateral image to a rectangle

    - by Will
    In the image below, the sign on the side of the van is not face-on to the camera. I want to calculate, as best I can with the pixels I have, what it'd look like face on. I imagine that this is some kind of loop through the x and y axis doing a Bresenham's line on both dimensions at once with some kind of mixing when pixels in the source image overlap - some sub-pixel mixing of some sort? What approaches are there, and how do you mix the pixels? Is there a standard approach for this?

    Read the article

  • Color scaling function

    - by Tomas Pajonk
    I am trying to visualize some values on a form. They range from 0 to 200 and I would like the ones around 0 be green and turn bright red as they go to 200. Basically the function should return color based on the value inputted. Any ideas ?

    Read the article

  • How can I manually interpolate string escapes in a Perl string?

    - by Ryan Thompson
    In perl suppose I have a string like 'hello\tworld\n', and what I want is: 'hello world ' That is, "hello", then a literal tab character, then "world", then a literal newline. Or equivalently, "hello\tworld\n" (note the double quotes). In other words, is there a function for taking a string with escape sequences and returning an equivalent string with all the escape sequences interpolated?

    Read the article

  • Approaches for animating a C# property over time?

    - by Mario Fritsch
    I'm currently trying to animate a bunch of public properties on certain objects. Usually they are of type float or vectors of floats (the type is known at compile-time). I want to be able to: assign a static value to them (MyObject.Duration = 10f;) or assign a random value to them by specifying a minimum and maximum value and optionally also a weight (MyObject.Duration = new RandomFloat(5f, 20f, 2f);) or "bind" this property to the property of another object (think of a child object binding some of its properties to its parent object, like its color or size or sth.) or assign sort of a keyframe animation to them, specifying a variable number of keyframes with timecode and the property's value at that specific point in time as well as information about how to interpolate between these frames The keyframes should be able to accept random values for each frame, both for the time and the property's value. What would be a practical approach for this kind of system? Currently I'm thinking about polymorphism: implement a base class or interface with a public Value-property and/or GetValue(float time)-method and then creating different sub classes like StaticValue, RandomValue, BindingValue and AnimatedValue implementing this base class or interface. Doesn't seem very elegant, though, and the initialization of even simple objects becomes a bit tedious. Another idea would be to implement these properties just as regular floats or vectors and create special "Modifier"-types binding to these properties. To retrieve the "real" value of the property, I'd first call any Modifier bound to the property, which would in turn update the actual object's property for me to retrieve later on. That would most likely mean using reflection at some point, which could be quite bad for performance as I'll probably have thousands of properties to update dozens of times per second. Any suggestions on this? Being a novice I'm (hopefully) missing some far more elegant and/or practical solution than I'm already playing around with :( Edit: Probably should have mentioned this earlier, but WPF isn't an option - it's not available on all targetted platforms, so I can't rely on it. I'm aware of its powerful databinding and animation capabilities, but I need to roll my own (or find some other lightweight alternative meeting my needs).

    Read the article

  • C# and C++ Library

    - by Betamoo
    I was wondering if I can use a library -written in C++- in C# The problem is that library has its own structures and classes.. Will I be able to use it in C#? Thanks

    Read the article

  • Is there a Java data structure that is effectively an ArrayList with double indicies and built-in in

    - by Bob Cross
    I am looking for a pre-built Java data structure with the following characteristics: It should look something like an ArrayList but should allow indexing via double-precision rather than integers. Note that this means that it's likely that you'll see indicies that don't line up with the original data points (i.e., asking for the value that corresponds to key "1.5"). As a consequence, the value returned will likely be interpolated. For example, if the key is 1.5, the value returned could be the average of the value at key 1.0 and the value at key 2.0. The keys will be sorted but the values are not ensured to be monotonically increasing. In fact, there's no assurance that the first derivative of the values will be continuous (making it a poor fit for certain types of splines). Freely available code only, please. For clarity, I know how to write such a thing. In fact, we already have an implementation of this and some related data structures in legacy code that I want to replace due to some performance and coding issues. What I'm trying to avoid is spending a lot of time rolling my own solution when there might already be such a thing in the JDK, Apache Commons or another standard library. Frankly, that's exactly the approach that got this legacy code into the situation that it's in right now.... Is there such a thing out there in a freely available library?

    Read the article

  • Linear Interpolation. How to implement this algorithm in C ? (Python version is given)

    - by psihodelia
    There exists one very good linear interpolation method. It performs linear interpolation requiring at most one multiply per output sample. I found its description in a third edition of Understanding DSP by Lyons. This method involves a special hold buffer. Given a number of samples to be inserted between any two input samples, it produces output points using linear interpolation. Here, I have rewritten this algorithm using Python: temp1, temp2 = 0, 0 iL = 1.0 / L for i in x: hold = [i-temp1] * L temp1 = i for j in hold: temp2 += j y.append(temp2 *iL) where x contains input samples, L is a number of points to be inserted, y will contain output samples. My question is how to implement such algorithm in ANSI C in a most effective way, e.g. is it possible to avoid the second loop? NOTE: presented Python code is just to understand how this algorithm works. UPDATE: here is an example how it works in Python: x=[] y=[] hold=[] num_points=20 points_inbetween = 2 temp1,temp2=0,0 for i in range(num_points): x.append( sin(i*2.0*pi * 0.1) ) L = points_inbetween iL = 1.0/L for i in x: hold = [i-temp1] * L temp1 = i for j in hold: temp2 += j y.append(temp2 * iL) Let's say x=[.... 10, 20, 30 ....]. Then, if L=1, it will produce [... 10, 15, 20, 25, 30 ...]

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >