Searching for advice: We are rewriting (in c#) the graphical user interface for the Watershed Risk Analysis Management Framework model, and are using the DotSpatial libraries for our map operations. We need to perform some simple tabulations on raster data, and I'm having trouble finding examples. We need to calculate land use (using national land cover dataset) percentages within polygons, calculate average slope and aspect within polygons. Pretty standard stuff for hydrologic analysis. Does anyone know of tutorials or available code sources for DotSpatial raster analysis? Thanks for your time.
did you find a way to do it? I am in the same position. For the moment, my current workaround is this. I have converted my raster into a List<GeoAPI.Geometries.IPoint> listPts using the center coordinates of the pixels, with the Z value as the corresponding raster pixel value. Then, with my PolygonShapefile, I loop over each feature, and use the feature.Geometry.Covers(listPts[i]) methode to build a list of the points failing in each polygons. After that, I simply cross the two lists together to calculates the corresponding statistics that I need.
I would like a better suggestion, but for the moment, it fits my needs.
Related
Is there possibility to get array of vertices stored within display list in opengl?
From some other code I get a display list which I should draw , but I need to know a bounding box of that model. Is there a possibility that I could extract that information from display list?
Have you considered using the feedback buffer, since this is deprecated OpenGL?
You can set the render mode to GL_FEEDBACK before drawing your display list and then get a buffer full of all the vertices. Since this is a rarely used feature and a deprecated one at that (transform feedback is the modern equivalent, though it functions in a different pipeline stage), some language bindings may not have it.
Unfortunately, the feedback buffer contains more than just vertices. It contains a list of all the raster operations that occurred, and you would have to build some software to make sense of this list. The OpenGL SuperBible has an example of how to do this in C.
The other thing to note is that vertex positions are in screen space, you will need to reverse project them into object space for this to work the way you want in your example. This also means that the original positions for any vertices that had to be clipped will be lost. It is far from a perfect solution, more of a hack if anything, but it could be useful.
No. The GL has no support for inspecting display lists. DLs are just for the GL, not for the user.
Having said that, there is still a theoretical possibility to get the contents of the DL. You could intercept all GL calls the code generating the DL is calling, track dlist state and compute the bounding boxes based on the vertex data. The old chromium open source project would in principle allow you to do this. However, the effort for this would be extraordinarily high, and I doubt that it would be a viable solution to your problem.
I want to recognize handwriting shape and figure out which shape it probably is in the set. Simply saying, if I draw a triangle, the application should recognize it as an triangle.
How can I do this using C# or java, any help is appreciated.
Thanks in advance.
These are some of the shapes I need to identify
You can try to use OpenCV for that. EmguCV is a good wrapper to OpenCV for .net. Watch for ShapeDetection demo (included in OpenCV)
If you want to "roll your own" I would suggest the following steps:
First, skeletonize (thin out the image till all the lines are one pixel thick). There are many ways to do this, and it is a well studied problem. Google for more information.
Now, starting at a black pixel, go through and trace out the outline of the image, one pixel at a time. You add each of these segments to a list of segments outlining the shape (each segment will be a simple line from one pixel to its adjacent pixel). Now you have the outline of your shape as a many-sided polygon.
(Possible step at this point: smooth the outline by pulling each vertex closer to the average of its neighbors)
Now, you use a corner detection algorithm to find the corners (take a look here:http://visual.ipan.sztaki.hu/corner/node7.html).
This should be enough to identify the shapes you have listed.
If you want to get smarter, you can also identify the types of edges that exist between corners. If the segment between two corners stays within some threshold of the straight line between them, you treat it as a "straight line" edge. If it doesn't, you treat it as a curving edge.
With corners +straight/curving edge, you probably could detect any of the shapes you are looking for pretty well.
I'd suggest using a neural network.
You could teach it what the shapes look like.
This is one library for example:
Neural Networks on C#
If you are looking for particular shapes inside a larger image then OpenCV is a great alternative. Emgu.CV is a good .Net wrapper for it. See my picture of a SURF implementation for this. Also see other options in OpenCV, it has plenty to offer. Note that this approach requires a lot of processing power.
If you can easily identify the shape you want as a BLOB (that is, give the algorithm a picture of only this shape) you can do a search for "ANN OCR" ("Artificial Neural Networks" and "Optical Character Recognition"). Many (most?) ANN-implementations come with sample code for feeding it shapes (letters) and recognizing closest shape (hand written letters). For example Neural Network OCR. I believe this approach would solve your problem. (Sidenote: I've encountered and tested numerous libs that can do this. It's Neural Networks 101.)
If you need BLOB algorithms for the ANN-OCR OpenCV can provide this.
Both these approaches are farily easy to implement.
There is indeed a vast tree of research in shape recognition.
If your shapes are indeed some what predictable and are basic geometry,
the most straightforward way is to find the edges and apply hough transform.
Some managable reading materials for you to start with,
[1] Google Scholar for Hough Transform Shape Detection
http://scholar.google.com/scholar?q=hough+transform+shape+recognition&hl=en&as_sdt=0&as_vis=1&oi=scholart
[2] Hough Transform # Wiki http://en.wikipedia.org/wiki/Hough_transform
im looking for a charting class library like Nevron or DevExpress that can handle with very big datasets (2 Millions points per second for example) are there better or more powerful Components? I need a few components to compare it among each other.
thanks
Did you checked the MS build in Charting Solution?
http://weblogs.asp.net/scottgu/archive/2010/02/07/built-in-charting-controls-vs-2010-and-net-4-series.aspx
It is for Winforms and ASP.net and as far as I remember there are plans to implement WPF support (<- but not sure)...
Download here: http://www.microsoft.com/downloads/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&DisplayLang=en
Documentation here: http://www.microsoft.com/downloads/details.aspx?FamilyId=EE8F6F35-B087-4324-9DBA-6DD5E844FD9F
You cannot physically show more than 300-1200 pixels/inch on a printer and a lot less on a display.
Take those 2 million points and summarise every group of 1000-odd points (via mean, median, mode, maximum or minimum...), so that you end up with 2000 'summarised' points (this would be quick and easy to code). Charting 2000 summarised points makes much more sense for on-screen charting. Use a summary range of 100-500 points, if it will be printed (depending on printer DPI capability and chart size).
Internally, this is what most charting components will have to do, in any case.
Unfortunately it is not that simple - when you "summarize" the points using average for example you'll loose spikes in the data. It also depends on the series being plotted - it is one thing to summarize in a line chart with ascending x values and completely different thing when you summarize a xy scatter point chart. It also depends whether the user has zoomed the chart etc. so a professional charting library will have to take the level of detail (zoom factor), data spikes and series type into account.
In addition some charting libraries will use a direct interface to the video board (like OpenGL or DirectX) which is must faster than when you draw using GDI+ for example. I think you 're going in the right direction as the above two libraries are some of the best out there.
As a pet project/learning experience (no this is not homework) I'm working on software to recognize barcodes from a photograph. I'm not looking for software or a library that does it - instead I'm using this as a learning exercise that I'm blogging about and will post up on Codeplex.
I have code that successfully recognizes EAN13 barcodes (which I published on CodePlex) and UPC version A/E should follow shortly. I have two areas that I'm concerned about, though. First is in decoding barcodes that are in a picture that is bit blurry or with poor contrast, etc. Second is in simply finding the actual barcode in a larger picture (right now you have to give me a photo of just the barcode).
I have the gut feeling that some form of AI is going to help me out here. I played a bit in the past with genetic algorithms and I took a course ages ago on AI so it's not totally foreign to me, but I'm not quite sure where to start.
What type of algorithm is best suited to this type of problem? Any recommended reading or code for the AI grunt work? Yes, I want to understand what's happening, but I don't necessarily want to go down to the level of coding the sorts, etc myself.
I would suggest to search for properties that a barcode has. Some that I have in mind are:
Histogram of colors shows two distinct colors in about even distribution
Doing a hough transformation finds many parallel lines
The thickness of the lines have two distinct dimensions.
Some other?
Having this I would split the image into pieces and do a classification with these features then cobine the results to calculate a liklyhood if the piece contains an barcode or not.
For your second problem (blurry image) I would suggest to calculate the 1st order derivative of the grayvalues and then detect the edges of the lines in this space. The maximum of the derivative is lower if the image is blurred but it should be detectable to a certain blurring factor.
Does this help you?
As mp already noted you don't necessary need any real AI technique for it. Have a look at chapter 12 of Real World Haskell. It implements an almost complete barcode recognizer. Sample code is in Haskell, but there is plenty of explanation, so you can probably understand the ideas and tricks even without Haskell experience.
If you want to solve it with AI then the best bet is probably using ANNs. For the given problem I would recommend to use a quite advanced technique called HyperNEAT. See my explanation (and links) as the first answer to the SO question Neural Network Size...
I would probably use two or three different networks,
The first one to find the barcode on the bigger picture. One output neuron per pixel/set of pixels, output value is the confidence if that pixel seems to be a part of a barcode. Based on the result I would use some image transformation to convert it to a "standard" format (x*y rectangle)
If you have difficulties with finding the location of the barcode use a second one. Feed the result of the first one, and ask it to give the coordinates of two corners. However, I'm not quite sure that it will be very easy to evolve this one.
Last one would work on the standardized format, output neurons for each line (or square, if you work with a possibly 2D barcode), saying if the given area should be considered black or white.
Probably it would also help to do some pre-processing of the image, e.g. those that are described in RWH.
You don't need any specific AI or softcomputing technique. You need to apply image processing technique to improve the quality of the image or to isolate the barcode from a larger image.
You could use Matlab for prototyping and learnig more about image processing.
image http://prod.triplesign.com/map.jpg
How can I produce a similar output in C# window forms in the easiest way?
Is there a good library for this purpose?
I just needs to be pointed in the direction of which graphic library is best for this.
You should just roll your own in a 3d graphics library. You could use directx. If using WPF it is built-in, you can lookup viewport3d. http://msdn.microsoft.com/en-us/magazine/cc163449.aspx
In graphics programming what you are building is a very simple version of a heightmap. I think building your own would give your greater flexibility in the long run.
So a best library doesn't exist. There are plenty of them and some are just for different purposes. Here a small list of possibilities:
Tao: Make anything yourself with OpenGL
OpenTK: The successor of the Tao framework
Dundas: One of the best but quite expensive (lacks in real time performance)
Nevron: Quite good, but much cheaper (also has problems with real time data)
National Instruments: Expensive, not the best looking ones, but damn good in real time data.
... Probably someone else made some other experiences.
Checkout Microsoft Chart Controls library.
Here's how I'd implement this using OpenGL.
First up, you will need a wrapper to import the OpenGL API into C#. A bit of Googling led me to this:
CsGL - OpenGL .NET
There a few example programs available to demonstrate how the OpenGL interface works. Play around with them to get an idea of how the system works.
To implement the 3D map:
Create an array of vectors (that's not the std::vector/List type but x,y,z triplets) where x and y are along the horizontal plane and z is the up amount.
Set the Z compare to less-than-or-equal (so the overlaid line segments are visible).
Create a list of quads where the vertices of the quads are taken from the array in (1)
Calculate the colour of the quad. Use a dot-product of the quad's normal and a light source direction to get a value to shade value, i.e. normal.light of 1 is black and -1 is white.
Create a list of line segments, again from the array in (1).
Calculate the screen position of the various projected axes points.
Set up your camera and world->view transform (use the example programs to get an idea of how to do this).
Render the quads and lines, OpenGL will do the transformation from world co-ordinates (the list in (1)) to screen space. Draw the labels, you might not want to do this using OpenGL as the labels shouldn't scale with distance from camera, otherwise they could get too small to read.
Since the above is quite a lot of stuff, there isn't really the space (and time on my part) to post working code (but someone else might add something if you're lucky). You could break the task down and ask questions on the parts you don't quite understand.
Have you tried this... gigasoft data visualization tools (Its not free)
And you can checkout the online wireframe demo here