interpolation

Extrapolating data with interp not producing accurate image

拟墨画扇 提交于 2019-12-03 20:38:31
I have a graph where the extrapolation does not match the initial interpolation. I would like the heatmap to fill the entire image. First, the interpolation code: library(akima) library(reshape2) xmin <- signif(min(CBLo2$MD1)) xmax <- signif(max(CBLo2$MD1)) ymin <- signif(min(CBLo2$MD2)) ymax <- signif(max(CBLo2$MD2)) gridint <- 100 fld <- with(CBLo2, interp(x = MD1, y = MD2, z = Abundance, xo=seq(xmin, xmax, length=gridint), yo=seq(ymin, ymax, length=gridint) )) df <- melt(fld$z, na.rm = TRUE) names(df) <- c("MD1", "MD2", "Abundance") df$MD1 <- fld$x[df$MD1] df$MD2 <- fld$y[df$MD2] contour

natural neighbour interpolation. error in calculating polygon intersection area

老子叫甜甜 提交于 2019-12-03 20:30:36
I am trying to write this algorithm in R. Does it exist in any package already?!? This is what I did (with help from SO and various blog posts): library(rgdal) library(ggmap) require("maptools") require("plyr") locations<- unique(cbind(data22[,1], data22[,2])) [,1] [,2] [1,] 24.9317 60.1657 [2,] 24.9415 60.1608 [3,] 24.9331 60.1577 [4,] 24.9228 60.1477 [5,] 24.9370 60.1545 [6,] 24.9491 60.1559 [7,] 24.9468 60.1591 [8,] 24.9494 60.1675 [9,] 24.9561 60.1609 [10,] 24.9218 60.1632 [11,] 24.9213 60.1605 [12,] 24.9219 60.1557 [13,] 24.9208 60.1704 [14,] 24.9233 60.1714 [15,] 24.9469 60.1737 [16,] 24

Interpolating 1 dimensional array using OpenCV

我只是一个虾纸丫 提交于 2019-12-03 17:29:10
I define an array of 2 values, and try to use the imgproc module's resize function to resize it to 10 elements with linear interpolation as interpolation method. cv::Mat input = cv::Mat(1, 2, CV_32F); input.at<float>(0, 0) = 0.f; input.at<float>(0, 1) = 1.f; cv::Mat output = cv::Mat(1, 11, CV_32F); cv::resize(input, output, output.size(), 0, 0, cv::INTER_LINEAR); for(int i=0; i<11; ++i) { std::cout<< output.at<float>(0, i) << " "; } The output I would have expected is: 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 What I get however is: 0 0 0 0.136364 0.318182 0.5 0.681818 0.863636 1 1 1 Clearly

Image interpolation mode in Chrome/Safari?

☆樱花仙子☆ 提交于 2019-12-03 16:27:08
问题 I need to have an image render with nearest-neighbor resizing and not the bicubic way that is currently used. I currently use the following: ms-interpolation-mode: nearest-neighbor; image-rendering: -moz-crisp-edges; This works in IE and Firefox, but not in Chrome and Safari. Are there any webkit alternatives or any other way to achieve this effect? 回答1: Edit: It's now possible with image-rendering: -webkit-optimize-contrast; . https://developer.mozilla.org/en-US/docs/CSS/image-rendering

Affine transform with interpolation

牧云@^-^@ 提交于 2019-12-03 16:14:00
I would like to do an affine transformation on a very low resolution bitmap and I would like to do it while preserving the maximum amount of information. My input data is a 1 bit 64-by-64 pixel image of hand written character and my output would be greyscale and higher resolution. Upon analysing the image I construct a series of affine transformations (rotation, scaling, shear, translation) what I could multiply into a single affine transformation matrix. My problem is that given the input image and my computed affine transformation matrix , how can I calculate my output image in the highest

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

我怕爱的太早我们不能终老 提交于 2019-12-03 14:31:10
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"). EDIT : For clarity, based on the comments, I'm not looking to change the ArrayList implementation. I'm looking for a similar interface and developer experience. As a consequence, the value returned will likely be interpolated. For

analogy to scipy.interpolate.griddata?

 ̄綄美尐妖づ 提交于 2019-12-03 14:02:10
问题 I want to interpolate a given 3D point cloud: I had a look at scipy.interpolate.griddata and the result is exactly what I need, but as I understand, I need to input "griddata" which means something like x = [[0,0,0],[1,1,1],[2,2,2]] . But my given 3D point cloud don't has this grid-look - The x,y-values don't behave like a grid - anyway there is only a single z-value for each x,y-value.* So is there an alternative to scipy.interpolate.griddata for my not-in-a-grid-point-cloud? *edit: "no grid

setting up a CUDA 2D “unsigned char” texture for linear interpolation

做~自己de王妃 提交于 2019-12-03 13:55:51
问题 I have a linear array of unsigned chars representing a 2D array. I would like to place it into a CUDA 2D texture and perform (floating point) linear interpolation on it, i.e., have the texture call fetch the 4 nearest unsigned char neighbors, internally convert them to float, interpolate between them, and return the resulting floating point value. I am having some difficulty setting up the texture and binding it to a texture reference. I have been through the CUDA reference manual &

Sparse Matrix Interpolation With MATLAB

こ雲淡風輕ζ 提交于 2019-12-03 13:43:34
If I have a matrix like this A = [1 2; 3 4]; I can use interp2 to interpolate it like this newA = interp2(A,2); and I get a 5x5 interpolated matrix. But what if I have a matrix like this: B = zeros(20); B(3,2) = 5; B(17,4) = 3; B(16, 19) = 2.3; B(5, 18) = 4.5; How would I interpolate (or fill-in the blanks) this matrix. I've looked into interp2 as well as TriScatteredInterp but neither of these seem to fit my needs exactly. A good solution is to use my inpaint_nans . Simply supply NaN elements where no information exists, then use inpaint_nans. It will interpolate for the NaN elements, filling

Stretching out an array

左心房为你撑大大i 提交于 2019-12-03 12:56:24
I've got a vector of samples that form a curve. Let's imagine there are 1000 points in it. If I want to stretch it to fill 1500 points, what is the simplest algorithm that gives decent results? I'm looking for something that is just a few lines of C/C++. I'll always want to increase the size of the vector, and the new vector can be anywhere from 1.1x to 50x the size of the current vector. Thanks! Here's C++ for linear and quadratic interpolation. interp1( 5.3, a, n ) is a[5] + .3 * (a[6] - a[5]), .3 of the way from a[5] to a[6]; interp1array( a, 1000, b, 1500 ) would stretch a to b . interp2(