ellipsoid or sphere in area calculations of terra? - cell

How the calculations of area are made in terra, when using geographical coordinates (lon/lat)?
1 - On a sphere or an ellipsoid?
2 - Using a constant width of the cells (the median width) as it was done in raster package, or using a more accurate algorithm?
My questions concern both the expanse and cellSize functions.
I tried to find the answers in the terra manual and the help pages, but I was not successful. Thank you for your help.

According to Robert Hijmans’ (#RobertHijmans) answer to this existing question (Why do terra::cellSize() and raster::area() produce different estimates of raster cell area?):
raster uses the product of the width (longitude) and height (latitude) of a cell. terra is more precise, it computes the spherical area of a cell (as defined by its four corners). This matters most at high latitudes, where the width of a cell changes most, and can be different between the bottom and the top of a cell. So the difference will be largest at high latitudes and with cells with a low vertical resolution.”
Dr. Hijmans also says:
"The bigger change in terra is that it also computes actual cell-size for projected (i.e. not lon-lat) rasters."
See the existing question linked above for examples from his answer. Hope that helps!

On a sphere or an ellipsoid?
The WGS84 ellipsoid
Using a constant width of the cells or a more accurate algorithm?
More accurate. See Christopher Crawford's answer

Related

Algorithm behind score calculation in FAST corner detector

How is the score for a detected corner is calculated in the FAST corner detector? I read the original paper "Machine Learning for High Speed Corner detection" but in the score calculation portion nothing is explicitly mentioned as to which N contiguous pixels they are referring at. Is it the N contiguous pixels that satisfy the corner criteria for that point? I also found the below link
https://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/AV1011/AV1FeaturefromAcceleratedSegmentTest.pdf that speaks of the FAST corner score computation . Also, I am not finding any correspondence between the score function described in this paper and the score calculation done by OPENCV for the bresenham circle of radius 3.
https://github.com/opencv/opencv/blob/master/modules/features2d/src/fast_score.cpp
The score has been calculated in the cornerScore<16> function in the above link. Besides these things, no other article explicitly talks about the FAST score calculation in Fast feature Detector. Can anyone kindly give me any insight on this?
N.B -I have also looked at the second paper "Faster and Better:A machine learning approach to corner detection" but it has no explicit mention about the score calculation.
The docs online confused me too:
The score function is defined as:
“The sum of the absolute difference between the pixels in the contiguous arc and the centre
pixel”
I'm pretty sure OpenCV doesn't calculate score like that. If you patiently read the source code you mentioned, you will find that the function cornerScore<16> is doing this:
Get 16 pixel values on the circle centered at the target pixel
Take a set of 9 contiguous pixels from the 16, calculate the absolute differences between the 9 pixels and the center one, and take the minimum (from 9 abs-diffs) value (which is called a threshold)
Take every pixel in the 16 as the beginning one of the step 2, and you will get 16 thresholds
Return the maximum threshold as the corner score
From this pipeline, you can see that the score OpenCV calculates is the maximum threshold that makes the target pixel a FAST-corner.

Calculating dispersion in Human Tracking

I am currently trying to track human heads from a CCTV. I am currently using colour histogram and LBP histogram comparison to check the affinity between bounding boxes. However sometimes these are not enough.
I was reading through a paper in the following link : paper where dispersion metric is described. However I still cannot clearly get it. For example I cannot understand what pi,j is referring to in the equation. Can someone kindly & clearly explain how I can find dispersion between bounding boxes in separate frames please?
You assistance is much appreciated :)
This paper tackles the tracking problem using a background model, as most CCTV tracking methods do. The BG model produces a foreground mask, and the aforementioned p_ij relates to this mask after some morphology. Specifically, they try to separate foreground blobs into components, based on thresholds on allowed 'gaps' in FG mask holes. The end result of this procedure is a set of binary masks, one for each hypothesized object. These masks are then used for tracking using spatial and temporal consistency. In my opinion, this is an old fashioned way of processing video sequences, only relevant if you're limited in processing power and the scenes are not crowded.
To answer your question, if O is the mask related to one of the hypothesized objects, then p_ij is the binary pixel in the (i,j) location within the mask. Thus, c_x and c_y are the center of mass of the binary shape, and the dispersion is simply the average distance from the center of mass for the shape (it is larger for larger objects. This enforces scale consistency in tracking, but in a very weak manner. You can do much better if you have a calibrated camera.

What does eigen value of structure tensor matrix denote?

It is known that good feature point across two images can be determined properly, if
the two eigen value of above matrix, are greater than 0. Can someone explain, what does it mean to have both eigen value greater than 0 and why the feature point is not good if either of them is approx. equal to 0.
Note that this matrix always has nonnegative eigenvalues. Basically this rule says that one should favor rapid change in all directions, that is corners are better features than edges or flat surfaces.
The biggest eigenvalue corresponds to the eigenvector pointing towards the direction of the most significant change in the image at the point u.
If the two eigenvalues are small the image at point u does not change much.
If one of the eigenvectors is large and the other is small this point might lie on an edge in the image but it will be difficult to figure out where exactly on that edge.
If both are large, the point is like a corner.
There is a nice presentation with examples in the panoramic stitching slide deck from a course taught by Rajesh Rao at the University of Washington.
Here E(u,v) denotes the Eucledian distance between the two areas in the vicinities of pixels shifted by the vector (u,v) from each other. This distance tells how easy it is to distinguish the two pixels from one another.
Edit The matrix of image derivatives is denoted H in this illustration probably because of its relation to Harris corner detection algorithm.
That is related with the concept of Texturedness in the paper of Thomasi-Shi "Good features to track".
The idea of Textureness is to provide a rating of texture to make features (within a window) identifiable and unique. For instance, lines are not good features since are not unique (see Figure 3.9a)
To solve equation an optical flow equation, it must be possible to invert J (Hessian matrix). In practice next conditions must be satisfied:
Eigenvalues of J cannot differ by several orders of magnitude.
Eigenvalues of Hessian overcome image noise levels λnoise: implies that both eigenvalues of J must be large.
For the first condition we know that the greatest eigenvalue cannot be arbitrarily large because intensity variations in a window are bounded by the maximum allowable pixel value.
Regarding to second condition, being λ1 and λ2 two eigenvalues of J, following situations may rise (See Figure 3.10):
• Two small eigenvalues λ1 and λ2: means a roughly constant intensity profile within a window (Pink region). Problem of figure 3.9-b.
• A large and a small eigenvalue: means unidirectional texture patter (Violet or gray region). Problem of figure 3.9-a.
• λ1 and λ2 are both large: can represent a corner, salt and pepper textures or any other pattern that can be tracked reliably (Green region).
Some references:
1 - ORTIZ CAYON, R. J. (2013). Online video stabilization for UAV. Motion estimation and compensation for unnamed aerial vehicles.
2 - Shi, J., & Tomasi, C. (1994, June). Good features to track. In Computer Vision and Pattern Recognition, 1994. Proceedings CVPR'94., 1994 IEEE Computer Society Conference on (pp. 593-600). IEEE.
3 - Richard Szeliski. Image alignment and stitching: a tutorial. Found.
Trends. Comput. Graph. Vis., 2(1):1–104, January 2006.

Finding curvature from a noisy set of data points using 2d/3dsplines? (C++)

I am trying to extract the curvature of a pulse along its profile (see the picture below). The pulse is calculated on a grid of length and height: 150 x 100 cells by using Finite Differences, implemented in C++.
I extracted all the points with the same value (contour/ level set) and marked them as the red continuous line in the picture below. The other colors are negligible.
Then I tried to find the curvature from this already noisy (due to grid discretization) contour line by the following means:
(moving average already applied)
1) Curvature via Tangents
The curvature of the line at point P is defined by:
So the curvature is the limes of angle delta over the arclength between P and N. Since my points have a certain distance between them, I could not approximate the limes enough, so that the curvature was not calculated correctly. I tested it with a circle, which naturally has a constant curvature. But I could not reproduce this (only 1 significant digit was correct).
2) Second derivative of the line parametrized by arclength
I calculated the first derivative of the line with respect to arclength, smoothed with a moving average and then took the derivative again (2nd derivative). But here I also got only 1 significant digit correct.
Unfortunately taking a derivative multiplies the already inherent noise to larger levels.
3) Approximating the line locally with a circle
Since the reciprocal of the circle radius is the curvature I used the following approach:
This worked best so far (2 correct significant digits), but I need to refine even further. So my new idea is the following:
Instead of using the values at the discrete points to determine the curvature, I want to approximate the pulse profile with a 3 dimensional spline surface. Then I extract the level set of a certain value from it to gain a smooth line of points, which I can find a nice curvature from.
So far I could not find a C++ library which can generate such a Bezier spline surface. Could you maybe point me to any?
Also do you think this approach is worth giving a shot, or will I lose too much accuracy in my curvature?
Do you know of any other approach?
With very kind regards,
Jan
edit: It seems I can not post pictures as a new user, so I removed all of them from my question, even though I find them important to explain my issue. Is there any way I can still show them?
edit2: ok, done :)
There is ALGLIB that supports various flavours of interpolation:
Polynomial interpolation
Rational interpolation
Spline interpolation
Least squares fitting (linear/nonlinear)
Bilinear and bicubic spline interpolation
Fast RBF interpolation/fitting
I don't know whether it meets all of your requirements. I personally have not worked with this library yet, but I believe cubic spline interpolation could be what you are looking for (two times differentiable).
In order to prevent an overfitting to your noisy input points you should apply some sort of smoothing mechanism, e.g. you could try if things like Moving Window Average/Gaussian/FIR filters are applicable. Also have a look at (Cubic) Smoothing Splines.

Computer Vision: Simple Noise Reduction

In computer vision, we often want to remove noise from an image. We can do this by getting an image and replacing distorted pixels with an average of its neighbours. I have no trouble understanding this but what are all the variables in the following equation meant to be? I've just found it in some slides but it doesn't come with any explanation:
The (i,j) is probably a given pixel and its neighbour, but what is the function f, the Omega, and the w? Any guesses?!
Cheers guys.
This is way too vague. Notation changes between papers and different approaches. Generally speaking that formula is doing some averaging within a neighbouring set of the i,j point (defined by the points in \Omega_{ij}) w is some normalization constant and f(m,n) is some function which typically assigns a value to m,n proportional to its distance from i,j
As I said your question is a bit too vague to say anything else...
This looks similar to motion prediction in video encoding.
g(i,j) is likely the ith, jth pixel in a block / screen. whose value is the weighted sum of another heuristic function taking the neighbor positions (m,n)
Since I see Omega I suspect you are working in signal space. This might filter out high frequencies not found in our neighbors m,n