Rotation using Bilinear Interpolation Backward Mapping Calculation? - image-processing

I just started learning Image processing.
Could someone help me explain this Step3 how to calculate these column? i really don't understand it. So please explain it simply as possible.
Rotation formula -> forward and backward mapping
Flowchart diagram and equations Step1
Forward mapping -> Step2
Backward mapping table1 Step3 <-- here is my question
Backward mapping table1(cont.) -> Step4
Forward mapping and Backward mapping result -> Step5

Related

Search for the optimal value of x for a given y

Please help me find an approach to solving the following problem: Let X is a matrix X_mxn = (x1,…,xn), xi is a time series and a vector Y_mx1. To predict values ​​from Y_mx1, let's train some model, let linear regression. We get Y = f (X). Now we need to find X for some given value of Y. The most naive thing is brute force, but what are the competent ways to solve such problems? Perhaps there is a use of the scipy.optimize package here, please enlighten me.
get an explanation or matherial to read for understanding
Most scipy-optimize algorithm use gradient method, for those optimization problem, we could apply these into re-engineering of data (find the best date to invest in the stock market...)
If you want to optimize the result, you should choose a good step size and suitable optimize method.
However, we should not classify tge problem as "predict" of xi because what we are doing is to find local/global maximum/minimum.
For example Newton-CG, your data/equation should contain all the information needed/a simulation, but no prediction is made from the method.
If you want to do a pretiction on "time", you could categorize the time data in "year,month..." then using unsupervise learning to "group" the data. If trend is obtained, then we can re-enginning the result to know the time

Affine relationship between input and output ports in Drake

Say I have a Drake Diagram with an input port and and output port. I happen to know that, holding the state of the diagram constant, these input and output ports have an affine relationship, i.e. y = A(x) u + b(x) where x is the full state of the Diagram. However, the Diagram is not explicitly an AffineSystem since its dependence on state is nonlinear.
What is the best way to generate a corresponding AffineSystem, or extract the matrices A and b for a given state of the diagram? Currently, I'm using
# set state
context.get_mutable_continuous_state_vector().SetFromVector(x)
# inputs to zero to get affine term
diagram.get_input_port().FixValue(context, np.zeros(k))
b = diagram.get_output_port().Eval(context)
# get linear term coefficient matrix
linearized = Linearize(
diagram,
context,
input_index,
output_index,
equilibrium_check_tolerance=1e20
)
A = linearized.D()
where the 1e20 tolerance basically just forces Drake to linearize the system even though it's not at an equilibrium. But I'm wondering if there's a more principled way to do this.
The reason I want to do this is similar to the question of this user about input allocation for underactuated systems. For a diagram consisting of a MultibodyPlant, Propeller, and a Multiplexer which multiplexes the input port to Propeller commands and JointActuator commands, I'd like to compute the affine relationship between inputs and generalized accelerations, so I can use this data in a QP for input allocation.
Thanks in advance for your help!
This is probably not a great way to do it, but you could consider to obtain A(x) and b(x) via the following process
First fix u to 0, then xdot is just b(x), as you have already done.
Now fix u to [1, 0, 0, ..., 0], then xdot is b(x) + A(x).col(0). You subtract b(x) obtained from step 1 from this result, and what left is A(x).col(0).
You repeat step 2 by setting u to the unit vector eᵢ, such that eᵢ(j) = δ(i, j). Then you get the i'th column of A(x).
Here is another possibility, if you like. Linearize is using AutoDiffXd to do this work. We also offer FirstOrderTaylorApproximation, which is effectively Linearize without the equilibrium check. You could make the autodiff calls yourself taking only the derivative with respect to u (eg for nominal u = 0), and it would give you exactly what you need.
Hongkai’s method has the advantage of not requiring and AutoDiffXd version of the system.

Best method to add generalized forces to Linearized (or LQR) MultiBodyPlant?

I'm trying to add generalized forces on a free-floating system that has been linearized from a MultiBodyPlant. For a fixed base, the generalized forces basically correspond to the joint torques but for a free-floating case, it includes the base torques/forces as well. However, these are not included in the actuation port of the MultiBodyPlant system and hence while providing the actuation port for linearization (or LQR), the base wrenches are not included in the actuation matrix B post-linearization. For my work, I'd like to include the base torques/forces as well in the linearization. For this, I can think of 2 approaches in drake but I'm not sure which would be a better/correct decision architecturally. I plan to use this later for making a TVLQR controller to stabilize trajectories.
Idea 1: Change B matrix in LQR after linearization: Manually edit B matrix after using LinearQuadraticRegulator(system, context, Q, R, plant_actuation_input_pot())
Idea 2: Create a LeafeSystem class (similar to this) with output port connecting to get_applied_generalized_force_input_port() and input port exposed outside diagram (using ExportOutput()) and then linearized this system as a whole (containing the CustomLeafSystem connected to MultiBodyPlant). I assume doing this will add the base actuation to the B matrix of the linearized system.
Actually these two ideas is what I would've done myself. For your case it'd seem that Idea 1 is simpler to implement?
Matrix B maps actuation indexes to generalized velocity indexes. Therefore you have to make sure that you place the necessary "ones" in the right places of B. You can find the free floating body indexes with Body::floating_velocities_start() which returns the start index within the full state x (therefore you'd need to subtract MultibodyPlant::num_positions() for indexing within B). For floating bodies generalized velocities are angular velocity w_WB and translational velocity v_WB, in that order. Therefore the generalized forces corresponds to the torque t_Bo_W and f_Bo_W applied at B about its origin Bo and expressed in the world frame.

Polynomial regression for one input feature

I am new to machine learning. I am having a question regarding polynomial regression using one feature.
My understanding is that if there is one input feature, we can create a hypothesis function by taking the squares and cubes the feature.
Suppose x1 is the input feature and our hypothesis function becomes something like this :
htheta(x) = theta0 + (theta1)x1 + (theta2)x1^2 + (theta3)x1^3.
My question is what is the use case of such scenario ? In what type of data, this type of hypothesis function will help ?
This scenario is for simple curve fitting problems. For example, you might have a spring and want to know how far the spring is stretched as a function of how much force you apply (the spring needn't be a linear spring obeying Hooke's law). You could build a model by collecting a bunch of measurements of different forces applied on the spring (measured in Newtons) and the resulting spring extension (also called displacement) in centimeters. You could then build a model of the form F(x) = theta_1 * x + theta_2 * x^3 + theta_3 * x^5 and fit the three theta parameters. You could of course do this with any other single variable problem (height vs. age, weight vs. blood pressure, current vs. voltage). In practice, you generally have many more than just a one dependent variable though.
Also worth pointing out that the transformations needn't be polynomial in the dependent variable (x in this case). You could just as well try logs, square roots, exponentials etc. If you're asking why is it always a parameter times a function of the input variable, this is more of a modeling choice than anything (specifically a linear model since it's linear in theta). It does not have to be this way and is a simple assumption that restricts the class of functions. Linear models also satisfy some intuitive statistical properties which also justify their use (see here)

how do I implement frequency domain adaptive filter in matlab?

My question is about the details of the frequency domain adaptive filter (fdaf) function provided in the DSP toolbox. This can be called as h = adaptfilt.fdaf which returns a structure, I think, in the variable h. This structure has all the parameters required to implement the filter, and the actual filtering of data is carried out using the function
[y, e] = filter(h, x, d)
where x is the input to be filtered and d is the desired output. y is an estimate of d.
adaptfilt.fdaf(...) can be passed many arguments, but I do not understand the use of most of the arguments, especially LAMBDA and LEAKAGE. The source code for the filter(h,x,d) function can be viewed, and most of the source code is a straight forward implementation of Overlap-Save algorithm (described in J.J. Shynk, "Frequency-domain and multirate adaptive filtering," IEEE Signal Processing Magazine, vol. 9, no. 1, pp. 14-37, Jan. 1992), but the theory does not include anything about the leakage or the lambda parameter (which appears in the filter function as an averaging factor). I am assuming that the designers of the filter function have modified their implementation to make the function as general as possible and so these concepts are related to some general filter theory, but I am unable to find any references to what they mean, how they affect the filter performance and why are they there in the filter function. Please help me if any one has any ideas about this, or have used the fdaf function of Matlab DSP toolbox before.

Resources