Opencv – how to interpolate between data points?

I am developing a software using OpenCV and QT to draw data points I need images that can fill in incomplete data I want to interpolate between the points I have Anyone can recommend a library or function that can help me I thought it might be the opencv remap method, but I can't seem to make it work

The data is a 2-D matrix of intensity values I want to create some images It is a school project

Solution

Yo! Big topic

The "right" answer depends on your question area and the details of what you are doing

Some choices need to be made to interpolate in one dimension I will assume that you draw on a regular grid, but some of your grid points have no data Big question: is the disadvantage sparse or large spots?

You can't add information, so you just want to build something that looks good

Conceptually simple recommendations (but there may be some work to implement):

For each area where data is missing, identify all edge points This is x found in this graph

oooxxooo
oox..xoo 
oox...xo
ox..xxoo
oox.xooo
oooxoooo

Among them is the defect data, X and o have data (for a single missing point, this will be the four nearest neighbors) The average value of each lost data point exceeds the edge points around this blob In order to make it smooth, each point is weighted 1 / D, where D is the distance between two points (delta x delta y)

From before, we have any details:

Have you ever tried linear interpolation without this information? If your data is quite dense, this may be done for you, and you can easily code when you need it

The next step is usually a cubic spline, but you may want to get an existing implementation

When I need something more powerful than fast linear interpolation, I usually use root (and choose a tspline class), but this may cost more than you

As pointed out in the comments, root is very big. Although it is fast, it does try to force you to do root, so it can have a great impact on your program

Linear interpolation between two points (x1, Y1) and (X2, Y2) (or actual extrapolation) is given

y_i = (x_i-x1)*(y2-y1)/(x2-x1)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>