In the example page it is shown how to do a neighbor search with a limit on the number of returned items. Is it possible to also specify a distance limit? I.e.:
Return all items that are at most X distance from the point, and further limit the result to Y number of items."
No, if you need distance, use OVERLAPS.
https://tarantool.org/doc/book/box/box_index.html#rtree-iterator
Related
I have an image like this one
with 3 distinct regions. Using a breath first 4 neighbor queue, I have implemented a basic flood fill that distinguishes between the 3.
Now I need to find the center of mass of these regions with each pixel weighing one unit of weight.
Whats the best way of going about that?
The simplest way is to keep three arrays, sumx, sumy and count, each with one entry per label (3 in your case), and all initialized to 0. Then run through the image once, and for each labeled pixel add the x coordinate to the corresponding bin in sumx, the y coordinate to the corresponding bin in sumy, and 1 to the corresponding bin in count.
At the end, for each label l you can compute sumx[l]/count[l] and sumy[l]/count[l]. These are the unweighted centers of gravity (centroids).
I am trying to find the fast way of block matching between 2 images and I am using sum of absolute difference (SAD) as similarity metric.
Given a reference block A at NxN size in frame 1, a full search for the best matched block within a search window of size (2W+N)*(2W+N) in frame 2, where W stands for the maximum allowed displacement. Full search block matching requires (2W+1)^2 comparison.
Integral image can calculate the sum of pixels in a block in any image quickly but I could not work out how to calculate the sum of absolute difference (SAD) here.
Is it possible to use the integral image to calculate SAD here? Thanks.
I want to use OpenCV Hough Circles' implementation, but I have a question:
the circles that this function returns are already sorted by vote?
Since Hough transform is based on a voting mechanism, I want to know if this circles are return in order from the most voted to the least voted, or in a random order.
Yes, they are sorted according to the vote in the accumulator in descending order.
You'll notice that in the function that actually computes the hough transform icvHoughCirclesGradient inside hough.cpp, where icvHoughSortDescent32s( &sort_buf[0], center_count, adata ); is called on the buffer containing the votes.
Note that (source) the centers are sorted according to the highest accumulated values based on circle centers with the highest vote from surrounding edge pixels, and not according to the number of supporting radius pixels. This make sense, since bigger circles would have higher support then.
How to count number of paths between two points in an N-dimension grid?
I know that this can be done in a NxN grid using the formula (x'+y')C(x') where x' and y' are the difference between the x and y coordinates of two points.
I m interested in a extension of above formula to higher dimensions.
For two dimensions, read up on Catalan numbers (http://en.wikipedia.org/wiki/Catalan_number). Note that the formula assumes monotonic paths.
Given an MKMapView that contains a variable amount of annotations ([mapView annotations]) at various points on the map and the MKMapRect value MKMapRectWorld, how can I determine an area on the map that has the greatest concentration on MKAnnotation objects (perhaps the 5-15 annotations closest to one another) ?
Example scenarios:
* Coffee finder: Determine which area of the map has the most Starbucks
* K9 statistics: Determine which area of the map has the most Cocker Spaniels
The "area" could be a set rect size or determined by a block of annotations, I don't necessarily care. Thanks for your help!
You will find related question helpful.
Also take look at K-means_algorithm
K-means_algorithm
If you have N annotations and want to break into K parts you can find center (which will fill certain criteria. e.g. minimize the within-cluster sum of squares ) of each of K parts with K-means-algorithm. Once you have center find out distance between center and annotation farthest from center it will give radius of region you are interested. There are several variations of K-means_algorithm, you can choose whichever based on performance and ease of implementation.
EDIT:
I have not implemented following, but think will definitely give one of solution
If you are OK with range 5-10, there can be multiple solutions. So we will find one of solution.
1- Say you have (N=100) annotations and want which (P =15) of them are most located densely.
2- Then we will divide N annotations in K = N/P groups(here K = 7) randomly
3- Use K-means algorithm so that finally we will have K groups that can be differentiated as separate entities.
4- These K groups will have property of minimum " within-cluster sum of squares".
5- If you want to save computational time, you can relax definition of most concentrated group as minimum "within-cluster sum of squares" as opposed to area bounded by them.
6- select a group from obtained K group that satisfies your criteria.
7- If want to persist to minimum area(greatest concentration) definition then you will need to do lots of computation
a. First determine boundary annotations of given group, which itself a huge problem.
b. calculate are of each polygon and see which is least. not complicated but computationally demanding)
EDIT2:
I tried whatever I can and finally thought it this question belongs to specialist math website. I asked your question here and from the answer , you can get paper discussing this problem and solution here. Problem they discuss is given N points, find the K points whose area of convex hull is minimum.