Subdivision of a Voronoi diagram that is still a Voronoi diagram, superset of the original one - triangulation

Consider an existing Voronoi diagram V built over a set of sites S. This diagram effectively solves the problem of a "postal offices servicing regions that are nearest to them than to any other site".
Consider that the problem of postal offices evolves in terms of the need of decentralization without redefining the borders. That is, instead of (or in addition to) the former sites there need to be more smaller sites within the current site's area that would have the same original "external" borders (but obvoiusly some new "internal" ones).
In terms of more formal definition, does there exist a subdivision of an existing Voronoi diagram that in turn is a new Voronoi diagram such that it is a superset of original set of sites and set of resulting edges?
EDIT1: Maybe even more formal: if D is a set of edges, D={E}, being the Voronoi diagram for set of points S: D=DV(S), then does there exist a set of new points S1, such that S'=S+S1, for which a new Voronoi diagram D'=DV(S')={E'} is a "superset" of original one: U{E} < U{E'}?

You can solve your problem with the point-to-location algorithm:http://en.m.wikipedia.org/wiki/Point_location. Maybe you can look into TOPOJSON and merge adjacent cells:http://bl.ocks.org/mbostock/9927735.

Related

How to get the position of connectors on a diagram in Enterprise Architect?

I have a usecase diagram with an actor and a usecase and there is an association between the two. I want to get the source and target position of the association on the diagram. I tried considering the SX,SY,EX,EY points of the connector in the PDATA5 column of the t_connector table but it doesn't make sense for most of the connectors as they are 0 in most cases.
Is there any other way to get the positions of the connectors on the diagram?
Well, it's complicated. EA renders connectors internally. In your case you have a plain rendering. So what EA does is to find the centers of the two connected elements by looking at the element positions on the diagram (via t_diagramobjects). As you might know, EA considers all elements to be rectangular. Use cases and actors the same. This is why connectors do not attach to visible borders but swivel around an invisible frame. Now the geometric centers are calculated and the attachment to those frames (which is simple geometry).
You need to look into t_diagramlinks for the connector as well, but only if you shift attachment point or introduce bends. And of course if you have special renderings (like tree style which makes completely different things you can't re-compute (simply)). The geometry will tell how shifts are made. And the path reveals the bends. Again just simple geometry if you have standard Custom Lines being set. For every other line style: you better don't ask.
From DB side:
t_diagramlinks.geometry (SX,SY)(EX,EY)=(0,0)(0,0) - probably the line from the center of the object to the center. EDGE - where the connector starts (1 top, 2 right, 3 bottom,4 left) from the source object, t_diagramlinks.path - additional break points etc.

Choosing a networkx layout that takes edge labels into account

I'm plotting networkx weighted graphs using the draw_networkx_edge_labels function. My problem is that, since edges sometimes cross each other, it is not always clear from the plot which weight belongs to which edge. For instance, in the following plot it is not immediately clear whether 2 is the weight of (1,2) or (3,7).
I'm currently using the neato layout, which does not take edge labels into account. In particular, this is how I'm drawing a weighted graph g:
layout = nx.nx_pydot.graphviz_layout(g, prog='neato')
nx.draw(g, pos=layout)
edge_labels = nx.get_edge_attributes(g, 'weight')
nx.draw_networkx_edge_labels(g, pos=layout, edge_labels=edge_labels)
I know I can manually control the position of the label along an edge using the label_pos parameter, but my question is whether there exists a way to automatically plot the graph such that edge labels do not usually collide (either using a layout that takes labels into account or a method that "neatly" selects label positions along edges).
I'm not expecting something that always works, but since my graphs are relatively sparsely connected, I hope there's a method that at least has a tendency to work well.
I have been meaning to implement this in netgraph, my fork of the networkx drawing utilities, for a while now. Unfortunately, I have a job interview on Thursday, so I won't have time to write this anytime soon. The basic idea, however, is pretty simple, and is also already implemented in some R packages such as ggrepel and also ggnetwork.
The basic idea is that you use a force directed layout to position your labels, given a predetermined and fixed layout for your nodes and edges. So:
Compute a node layout using the layout of your choice.
Partition each edge into a chain of many, many nodes, and compute the positions of the "edge nodes" using the already known positions of the source and target nodes of the edge. This partitioning is to give each edge a "mass" in the following force directed layout.
For each edge, add a "label" node and connect it to the most central "edge node".
Compute a force-directed layout keeping all nodes but the label nodes fixed (e.g. using spring_layout in networkx).
You should now have sensible edge label coordinates that do not overlap any of the edges. Use plt.annotate to plot a connection between the edge and the edge label.

POSTGIS: Dissolve Multi-polygons to enable joined classification

I have a number of spatial database, through which I have identified particular types of land-cover. The topographic layer [defining land-cover] is made up of multi-polygons and I am using a separate point layer in order to join a classification type to it. However, the areas portrayed in the topographic layer may be formed from several individual polygons, without a total perimeter outline to identify the area. Therefore, the classification point may sit in just one individual polygon of the overall area [see below].
Example. Image is of a park, which consists of over 20 individual polygons. The point that classifies the area as a park sits within one of the polygons and cannot be attached to the entire area.
I would like to be able to apply the point based classification to the whole park area. I have tried to use ST_UNION function in order to do such, but have been unable. Does anyone know of a way to dissolve the area into a single shape/remove the pathways? This is a small example of a much larger data set, where there is little scope of manually defining area sand buffers in order to classify the data, thus I wondered if there was a practicable solution.
If anyone can help, it would be hugely appreciated....
SELECT ST_Collect(t.the_geom) as singlegeom FROM TABLE t; http://postgis.net/docs/ST_Collect.html

Why do MSER results have overlapping pixels

First, I'm using opencv MSER via matlab via 2 different methods:
Through the matlab's detectMSERFeatures function. This seems to call the
opencv MSER (via the call to ocvExtractMSER in the detectMSERFeatures function)
Through a more direct approach: opencv 3.0 wrapper/matlab bindings found in https://github.com/kyamagu/mexopencv
Either way, I can get back lists of lists of pixels (aka regions) that I imagine are a translation of the opencv MSER::detectRegions 2nd arg, "std::vector< std::vector< Point > > &msers"
The result can end up a list of multiple regions each region with its own set of points. However, the points of the regions are not mutually exclusive. In fact, they typically, for my data in which the foreground is typically roundish blobs, tend to all be part of the same single connected component. This is true even if the blob doesn't even have any holes (I might understand if the regions corresponded to contours and the blob had holes).
I'm assuming that this many-region-to-one mapping of regions to even a solid blob is due to opencv's MSER, in its native C++(?) implementation, doing the same but I confess I haven't verified that (but I surely don't understand it.)
So, does anybody know why MSER would yield multiple overlapping regions for a single solid connected component? Is there any sense to choosing one and if so how? (Right now I just combine them all)
EDIT - I tried an image with one blob which then I replicated to have a single image where the left half was the same as the right (each half being the same, each with the same blob). MSER returned 9 lists/regions all corresponding to the two blobs. So, I wold have to do connected component analysis just to figure out which subsets of the regions belonged to what blob and so apparently there can't be any straightforward way to choose a particular subset of the returned regions that would give the best representation of the two blobs (if such a thing was even sensible if you knew there was just one blob as per my last pre-edit question)
The picture below was made by plotting all 4 regions (lists of points) returned for my single blob image. The overlay was created by:
obj = cv.MSER('MinArea',20,'MaxArea',3000,'Delta',2.5);
[chains, bboxes] = obj.detectRegions(Region8b)
a=cellfun(#(x) cat(1,x{:}),chains,'UniformOutput',false) % get rid of extra layer of cells that detectRegions seems to give it.
% b=cat(1,a{:}); % all the regions points in a single list. Not used here.
ptsstrs={'rx','wo','cd','k.'};
for k=1:4
plot(a{k}(:,1),a{k}(:,2),ptsstrs{k},'MarkerSize',15);
end
So, you can see they overlap but there also seems to be an order to it where I think each subsequent region/list is a superset of the list before it.
"The MSER detector incrementally steps through the intensity range of the input image to detect stable regions. The ThresholdDelta parameter determines the number of increments the detector tests for stability. " This from Matlab help. It's reasonable that you find overlap and subsets. Apparently, the region changes as the algorithm moves up or down in intensity.

Half-Edge Collapse

I'm currently trying to implement a half-edge collapse in order to perform incremental remeshing. I'm dealing with a manifold mesh. Consider the following simple mesh:
The goal is to collapse a into b.
In this case however, this results in a non-manifold mesh
which I want to prevent. My question is:
How can I do this in advance, i.e. perform a check before the collapse whether the collapse operation is safe?
I've tried the criteria (link condition) from Hoppe, but both are fulfilled as it seems. Also, the only intersection of the one-rings of a and b is c, thus only one point as it is a boundary edge.
Also generally speaking, what other checks do I need to perform to avoid an illegal collapse?
Right now, I have the following criteria:
if a and b are boundary vertices, the edge ab must be a boundary edge
a, b and the third vertex of triangles adjacent to edge ab must be a valid triangle (link condition)
if triangles adjacent to edge ab are boundary triangles, do not collapse if a is on the boundary edge
if the intersection of the a-1-ring and b-1-ring is not equal to two (or one for boundary edges), do not collapse
You may want to look at this paper:
Tamal Dey, Herbert Edelsbrunner, Sumanta Guha, and Dmitry Nekhayev. Topology preserving edge contraction.
I'm not sure which Hoppe's paper you are referring to (progressive mesh?) but Tamal Dey's link condition is different from the one you stated. Intuitively, an edge ab is collapsible if
one-ring(a) intersected with one-ring(b) == one-ring(ab).
For an edge ab, one-ring is the set of the other vertices of the faces sharing ab. Also in Tamal Dey's link condition, you need to take the dimension of the embedding space into consideration. (i.e. the link condition is different for an edge in 2d and in 3d). Many other work use this link condition to collapse edges without incurring topological errors.
What's confusing is from your example I couldn't really tell whether it's a mesh-with-boundary in 3d or 2d, or how "planar" it is. These factors determine whether the resulting mesh has a "folding" or not, e.g. triangle bcd is considered folded in 2d but could be fine in 3d if the mesh is not planar.