What algorithm can I use to produce a weighted-cartogram such as the one below: ?
I can generate a shapefile plot using code from R, .NET libraries and also using PostGIS. However I can't find the search terms to use to find an implementation of the algorithm used to produce these warped shapefile plots. Not necessarily looking to plot only world maps, so must be able to work with an arbitrary shapefile.
So as mentioned in the OP's comments, these are called area cartograms. The neatest lil implementation I know of is cartogram.js, which relies on the magical D3 library. If that page ever happens to go down, you should be able to find a similar page by Googling "D3 area cartograms", and if that doesn't get you anywhere then the original paper on the topic was Dougenik 1985.
The D3.js answer, by Andy, is excellent, however, just for completeness, there is an implementation here, Cartogram algorithm, which comes from a Python plugin for the excellent open source GIS application, QGIS. The original paper and algorithm are cited in the comments. The full source code directory for the QGIS plugin is: https://code.google.com/p/ftools-qgis/source/browse/trunk/cartogram/?r=115
I realize that you asked for C#, and there are some QGIS geometry objects in the code, but the TransformGeometry method does illustrate how the algorithm works, QGIS reads shapefiles, and in case you wanted to do any other GIS style processing, QGIS would be a good option.
Related
I want to restart with data structure ( and Ai + I want to clear all my misconceptions too. ;P )
For now I want to know how would I put given pictorial info into algorithm using C# structure. Image processing is not required here. Just need to feed the data in.
Here I need this question to be modified too if not clear. :|
Say Arad is a city in Romania from where I have to go to another city Bucharest.
This map also has info of how far all connecting cities are from any city.
How would I use these info in program to start with any searching or sorting algo?
Any pointer will be helpful. Say if this can be done using anything else than struct. Something like node or something. I don't know.
Please consider I want to learn things. So using C# for ease in use not to use its inbuilt searching and sorting functions. Later to confirm I might use.
The way you typically solve this problem is to create a node class and an edge class. Each node has a set of edges that have "lengths", and each edge connects two nodes. You then write a shortest-path algorithm that determines the least-total-length set of edges that connects two nodes.
For a brief tutorial on how to do that, see my series of articles on the A* algorithm:
http://blogs.msdn.com/b/ericlippert/archive/tags/astar/
Although it's not exactly what you're looking for, Eric Lippert's series on graph colouring is an excellent step-by-step example of designing data structures and implementing algorithms (efficiently!) in C#. It has helped me a lot; I highly recommend reading it. Once you've worked your way through that, you will know much more about C# and you will understand some of the specific design tradeoffs that you may encounter based on your specific problem, including what data structure to use for a particular problem.
If you just want to look at raw algorithms, the shortest path problem has many algorithms defined for it over the years. I would recommend implementing the common Dijkstra's algorithm first. The Wikipedia article has pseudocode; with what you get out of Eric Lippert's series, you should be in good shape to develop an implementation of this. If you still want more step-by-step guidance, try a search for "Dijkstra's algorithm in C#".
Hope that helps!
What would be the best library choice for finding similar parts in images and similarity matching?
Thank you.
It sounds like the Scale Invariant Feature Transform (SIFT) is probably the algorithm you're really looking for. Offhand, I don't know of any general-purpose image processing library that includes it, but there are definitely standalone implementations to be found (and knowing the name should make Googling for it relatively easy).
ImageJ fastest image processing library in Java.
OpenCV is certainly a solid choice as always.
That said, VLFeat is also very good. It includes many popular feature detectors (including SIFT, MSER, Harris, etc.) as well as clustering algorithms like (kd-trees and quickshift). You can piece together something like a bag of words classifier using that very quickly.
While SIFT is certainly a solid general purpose solution, it actually is a pipeline composed of a feature detector (which points are interesting in the image), a feature descriptor (for each interesting point in the image, what's a good representation), and a feature matcher (given a descriptor and a database of descriptors, how do I determine what is the best match).
Depending upon your application, you may want to break apart this pipeline and swap in different components. VLFeat's SIFT implementation is very modular and lets you experiment with doing so easily.
Never did image processing, but I've heard from friends OpenCV is quite good, they usually use C++
I'm looking for some sample projects to read CAPTCHA images. Is there any in C# or VB ?
pseudo code:
String captchaText = CaptchaDecoder(Image captchaImage);
Take a look to:
Text-based CAPTCHA Strengths and Weaknesses. ACM Computer and Communication security 2011 (CSS’2011). link
The authors present a CAPTCHA breaker and explain a generic algorithm to crack standard CAPTCHAs
In this section we present our captcha breaker, Decaptcha, which is
able to break many popular captchas including eBay, Wikipedia and Digg
[...] Decaptcha implements a refined version of the three stage
approach in 15,000 lines of code in C# [...]
This is easier said than done.
This involves either brute-forcing the captcha or running OCR algorithms on it to try and detect what is written in the captcha.
You might want to check this related question: Has reCaptcha been cracked / hacked / OCR'd / defeated / broken?
It also depends on what techniques were used to produce the CAPTCHA. Some distort the text and some squeeze the text.
Your question is a little vague.
Additional reading here: http://en.wikipedia.org/wiki/CAPTCHA
Christian
There are so many types of Captchas out there that you won't find a single library to read them all. If you are only interested in one type though, you might have more luck. Even then, there are lots of variations on Captchas, and the engines frequently produce (whether on purpose or incidentally) tricky ones which even humans can't figure out. Humans can click the little icon to get a new one; your program might not be able to.
I need to visualize a graph. I don't know how to name it (by the way, if you know - I'll appreciate if you tell me). It would be ideal for graph elements to be clickable (so that when user clicks on a block, I can handle an event with the element id specified) but I can survive even without any interactivity. I may like to be able to focus on a particular node and layout all others to view from its perspective. Are there any components available good for this task? If no, what should I look for to help me to develop an algorithm for drawing such a graph with visually-comfortable layout?
Practical nature of this graph is pretty common: each block represents a derivation from 2 operands. Orange circles are references to 2 operands, green circles are connection points to consumers. It can be significant to distinguish an operand position (left or right), for example if a derivation represents a mathematical operation of difference or division (in this particular case a block can be triangular, but in other cases an operand itself can make use of being aware of for what blocks is it a left operand and for what blocks is it a right). Another common application is intersecting sets with complex relations.
You could take a look at Graph#, but I'm not sure how well it'll handle composite nodes like that. It could be a good starting point though.
I also would like to point you to graphviz. It is not a .NET solution but you can feed it files that are easy enough to write in order to create graphs. I don't think layouting is a very simple thing to do, especially with increasing node count, so it should be a good thing to find some tool for that.
As It seems Microsoft itself has done a really good job on graph visualization called automatic-graph-layout.
Here's the link https://github.com/microsoft/automatic-graph-layout.
Well, you first need to represent it somehow in memory, there are many ways, like adjacency list. Then you need to draw it. While generally drawing a graph is simple, it's not that simple if you need to layout it. Looks like in your case, that's exactly what you need to do to come to that nice representation. It ain't going to be easy.
EDIT: Interesting, there seems to be a library made by Microsoft Research.
I don't know how useful it will be in this particular scenario, but you might want to take a look at http://quickgraph.codeplex.com/
Graphviz4Net provides WPF component for graphs visualization. It depends on GraphViz (open source command line graph visualization tool).
I can not find this component and i decided writen my own control, line and head, and use them to visualization my graph's
If the needed your i can give it's component and program to demonstrate him/
I writen component and program's in visual studio 2008 language C#
This is a fairly new and maintained .NET wrapper for Graphviz: https://github.com/Rubjerg/Graphviz.NetWrapper
(Disclaimer: I'm the author)
This wrapper works differently from other wrappers, since it makes direct function calls to the native Graphviz code. This means you can not only programatically construct your graph in C# code, but also read the layout attributes back out in C# code and render it any way you want. The latter sounds specifically like something you would be interested in.
A quite good looking one is the Diagram tool from Nevron. But it's not for free!
I'm currently using the charts and user interfaces from them and they work quite good.
Have used this commercial product with success: GoDiagram
It support the multiple ports on the nodes like you have shown.
I need to write some code that will buffer a line to create a polygon as shown below.
http://www.sli.unimelb.edu.au/gisweb/BuffersModule/Buff_line.htm
From following the steps outlined, I can create polygon shapes around simple lines that do not cross themselves or have too tight curves, but as the lines I'm trying to buffer are squiggly swhirly hurricane tracks, it's really not good enough.
I know there's a function in SQL Server 2008 that can do this, but I'm afraid that's currently a no go.
Can anyone point me in the direction of a more complete algorithm I can follow, or any background info that could help me figure this out?
Although this is called buffering in GIS, apparently the mathematicians who work on algorithms call it the Minkowski sum. Googling found this page by algorithm expert Steven Skiena that links to several algorithm implementations and some books. Hope this helps!
One of the algorithm implementations it links to right now (March 09) is CGAL, an open source C library.