Heatmap Tools For Web Apps - heatmap

I have a client that want to have a web app I'm building for them display heat maps of the data.
I haven't worked with heat maps at all and I was wondering if anyone knew of some good tools for generating them.
Thanks.

Heat maps are often used in place of a more conventional term: kernel density estimators. If you need to compute these on the fly, consider GRASS GIS- specifically, the v.kernel or v.neighbors modules. These will generate a continuous estimate (i.e. raster surface) of density, at some target resolution (defined by the current region settings). GRASS GIS can be controlled via Python code, so it would be a simple matter to write a Python wrapper around the underlying modules, that could export the results to your web application.
For small datasets, the R project has several functions for reading/writing spatial data, and computing kernel density estimates.

I realize this is an old, old post -- but the next guy to stumble across this page might try gheat for heatmaps in webapps. There are ports for Django and Google App Engine, if you happen to be using those backends.

I'll assume this is data with three values per data-point - we'll call them x, y and z.
It would really help if x and y were spatial coordinates as that makes things easier.
Anyway, generate a bitmap of x by y (scaled appropriately).
For each x and y pair in the data, scale z to between 0 and 1 (or 0 and however many colours you have in your map), and plot z as a colour represented by that value.
E.g. a simple map could just use the R portion of RGB, in which case you'd have 256 graduations for your red.
Most likely, you'd want something more fancy, but you should be able to get the idea.
If your datapoints are spread apart, you can either plot them as rectangles that take up the space, or smoothly interpolate between them.
NOTE: THere is a web-based tool that does it here. I found it linked from the Wikipedia article on heatmaps. There's a java one too linked from there too.

If you want to generate heatmaps on the clientside (with JavaScript) I can recommend heatmap.js to you. It uses the HTML5 Canvas element to generate dynamic web heatmaps, you can new add data at any time and the heatmaps refresh.

Pyheat is another good library in python for building heatmaps.
Gheat is already mentioned in a reply by J.J.

I have a compelling heatmaps tool for both PC and mobile web pages to recommend: http://miapex.com

Might I suggest my own jQuery plugin?
jQuery Hottie makes it easy to take normal markup and add a background color like so:
<!-- Coloring elements is easy! -->
<ul id="example1">
<li>1<li>
<li>2<li>
<li>3<li>
<li>4<li>
<li>5<li>
</ul>
$('ul#example1 li').hottie();

Related

Doing an Image Search?

Is it possible to perform an image search with google maps? For example, if I had a small section of a map, showing road configurations, but there were no labels to indicate street names or place names, is there a possible way to do an image search, similar to what you can do with regular google, to be able to identify that location? I have tried this with the regular google, and it does not work. Does anyone know of software or an app that has the ability to do this? Thanks!
Yes it may be possible , But I do not think any software or app that is currently available a program would be need to be written that takes that small section of a map that you have and it would have to be a rather good quality image and preferaby in a raw Bitmap format and then the small section of the map you provide would have to be overlaid over the main google map and then moved around the map... scanned and each pixel compared frame by frame as the search picture is scanned across the bigger map and then a best-fit process would be utilized , and then when it finds a match it can then let you know just how closely it matches and what the confidence level it is that that the location found is actually correct , it would be best to narrow it down as much as possible as well, also a bit of artificial intelligence might be very useful here too, a face recognition A.I. program could be modified to complete that task. but as far as I know none of that exists in a single readily available app or program , maybe someday someone would create such a program? it is possible.

central coordinates of regular map tiles

I am trying to retrieve a set of static map tiles from Google Maps using the simple web services API.
For zoom level 0, where there is only one tile, I simply specify the center as (0,0), which is trivial. (And yes, I am aware, that the south-north range is [-85.05113°,85.05113°] only, i. e. I have read about Mercator projection (not only the Wikipedia article).
So for zoom level 1 with 2×2 tiles I know that it'd be naive to think the central coordinates of the tiles would be (±90,±45). I applied one of the functions listed in above article's "Derivation of the Mercator projection" section. In PHP this looks like
function mercor($aLat) {
return rad2deg(asinh(tan(deg2rad($aLat))));
}
which always returns 50.498987 when passing in 45. I tried several of the alternative expressions :-) all with the same result, indeed, and even checked that value with a dedicated calculator.
Anyway, the value is obviously not correct, as you can see here (which was supposed to show the north west quadrant of the Earth's map, but here the equator is shifted to the north) (image source):
By trial and error I found the correct value to be close to 66.65, but I have no idea how to calculate that. I tried several manipulations of the R factor shown in the expressions in that mentioned "Derivation of the Mercator projection" section, and also fiddled with the "Scale factor" described in the same document, but whatever I do, I do not come close to 66.65.
Here you can see that 66.65 is the (close to) correct value, the equator at the bottom edge (image source):
And taking an illustration like, for example (image source):
and a tool like kruler, it also becomes obvious that it should be 66.65.
So, any idea would be greatly appreciated. Thanks in advance...
(Currently I'm trying it from withing HTML documents, because it's relatively simple, but later I'd like to do it from an environment in which I have no way to call JavaScript. so the JavaScript API is not an option.)
I have prepared a website describing the popular tiling system used behind Google Maps, OSM and similar slippy maps. Have a look at:
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
With a click on the interactive map you receive bounds calculated in both the Mercator coordinates (in meters) as well as WGS84 lat/lon (in geodetic degrees).
Down on the page you find an open-source python code (which has been in the meanwhile ported to other programming languages by other people). This contains documented description of all the math you may need.
In fact, I have created this resource after working for Google SoC on the GDAL2Tiles/MapTiler project - which has been reimplemented into C/C++ and significantly improved and is now available via http://www.maptiler.com/.
UPDATE:
If you want to use the Google Maps Static API requests you may find useful another online tool which I prepared: http://www.maptiler.org/photoshop-google-maps-overlay-tiles/.
Feel free to review the JavaScript source code.

Plotting tools for dashboard

After browsing for a while for available solutions, it is really hard to choose the most appropriate tool for creating dashboard & populating it with plots. I would want to have an html page with multiple plots and tables depicted. I'm thinking to have data input stored in csv files, appropriately formatted.
The requirements are:
plot coordinates are showing on mouse hover
ability to show coordinates of points on a plotted line (points in
scatter plot or bar values for bar chart) 'sticking' to the nearest
lines on hover, with appropriate handling of multiple lines (show several y values for same x)
ability to interactively switch plotted data on/off
easily embeddable into html page, doesn't require additional plugins installed
a good variety of plot types
not too slow to load and stable, there could be ~50 plots on one page
(this is for internal use only, so quickness is not that important)
does it all with minimal effort
So far I checked out (by no means a final opinion, correct me if I'm wrong):
gnuplot+canvas - looks good, but samples on their page fail to work
well for me, not always getting mouse clicks right
python+matplotlib+mplh5canvas - feels a bit raw, as I understand
some of the stuff above I'd need to implement in Python myself
RGraph looks awesome at first glance, not sure if it is good since never heard of
it and don't have any experience in js, hard to customize(?)
some other random stuff which seemed bad enough
Suggestions?
RGraph looks awesome, and is awesome. It's not difficult to use and there are a lot of examples online.
Rgraph Example page
They've got 22types of graphs, correct me if I'm wrong, and as I already said, easy to use.
Documentation about possibilities and stuff for each type of graph is also available on the website.
I end up using Highcharts because of its very advance features and ready-to-use templates (in addition to the things mentioned in the question).

Depth map (2d+z) algorithm or software

I'm searching for Depth map algorithm for action scrip 3 (or some other language).
My goal is to generate depth map for static image on run time.
I have fount this example http://kode80.com/2009/06/29/papervision-zbuffer-and-dof/, i didn't have the time to investigate it's code but i have the filling its working only with 3d models.
Worst viable option is server side technology that does the work.
Extended description:
I have a task to develop flash application where 3d rotation of a head is simulated by a 2d image uploaded by the user.
There are some japan guys that have managed to do that (http://hairtry.jp/), but the technology that they are using is server side. It generates swf fail with precisely coped eyes and image for the depth map of the uploaded picture. I can't find out what is the sever side technology that they are using so I'm searching for any posible workarounds.
Thanks in advance.
Cheers,
Chavdar Slavov
your easiest solution would be to use a 3d engine, Paper vision seems to be getting out dated, theres a lot of documents on how to use, and tutorials but again not much has been happening with them lately. i suggest Away3d "www.away3d.com" they seem up to date.
for what your asking it is possible to do this 100% in flash but to create a 3d head at runtime and fill the face with hieght maps this is possible, you would need to look at bitmap manipulation.i dont think this is an easy task, what you should learn first is how to add an image to a spheric surface dynamically than look into height mapping by converting certain coulours from the image into different levels of depth i must say im sure this is advanced stuff, i manged to animate a globe that was this same method it looks dodgy but it gives you some source code in the FLA
http://www.ffiles.com/flash/animations/globe_animation_3496.html
The above link will allow you to download my source files, the animation it self is a scrolling image but i used Actionscript to give the globe depth and a sheric look

document image processing

I working on an application for processing document images (mainly invoices) and basically, I'd like to convert certain regions of interest into an XML-structure and then classify the document based on that data. Currently I am using ImageJ for analyzing the document image and Asprise/tesseract for OCR.
Now I am looking for something to make developing easier. Specifically, I am looking for something to automatically deskew a document image and analyze the document structure (e.g. converting an image into a quadtree structure for easier processing). Although I prefer Java and ImageJ I am interested in any libraries/code/papers regardless of the programming language it's written in.
While the system I am working on should as far as possible process data automatically, the user should oversee the results and, if necessary, correct the classification suggested by the system. Therefore I am interested in using machine learning techniques to achieve more reliable results. When similar documents are processed, e.g. invoices of a specific company, its structure is usually the same. When the user has previously corrected data of documents from a company, these corrections should be considered in the future. I have only limited knowledge of machine learning techniques and would like to know how I could realize my idea.
The following prototype in Mathematica finds the coordinates of blocks of text and performs OCR within each block. You may need to adapt the parameters values to fit the dimensions of your actual images. I do not address the machine learning part of the question; perhaps you would not even need it for this application.
Import the picture, create a binary mask for the printed parts, and enlarge these parts using an horizontal closing (dilation and erosion).
Query for each blob's orientation, cluster the orientations, and determine the overall rotation by averaging the orientations of the largest cluster.
Use the previous angle to straighten the image. At this time OCR is possible, but you would lose the spatial information for the blocks of text, which will make the post-processing much more difficult than it needs to be. Instead, find blobs of text by horizontal closing.
For each connected component, query for the bounding box position and the centroid position. Use the bounding box positions to extract the corresponding image patch and perform OCR on the patch.
At this point, you have a list of strings and their spatial positions. That's not XML yet, but it sounds like a good starting point to be tailored straightforwardly to your needs.
This is the code. Again, the parameters (structuring elements) of the morphological functions may need to change, based on the scale of your actual images; also, if the invoice is too tilted, you may need to "rotate" roughly the structuring elements in order to still achieve good "un-skewing."
img = ColorConvert[Import#"http://www.team-bhp.com/forum/attachments/test-drives-initial-ownership-reports/490952d1296308008-laura-tsi-initial-ownership-experience-img023.jpg", "Grayscale"];
b = ColorNegate#Binarize[img];
mask = Closing[b, BoxMatrix[{2, 20}]]
orientations = ComponentMeasurements[mask, "Orientation"];
angles = FindClusters#orientations[[All, 2]]
\[Theta] = Mean[angles[[1]]]
straight = ColorNegate#Binarize[ImageRotate[img, \[Pi] - \[Theta], Background -> 1]]
TextRecognize[straight]
boxes = Closing[straight, BoxMatrix[{1, 20}]]
comp = MorphologicalComponents[boxes];
measurements = ComponentMeasurements[{comp, straight}, {"BoundingBox", "Centroid"}];
texts = TextRecognize#ImageTrim[straight, #] & /# measurements[[All, 2, 1]];
Cases[Thread[measurements[[All, 2, 2]] -> texts], (_ -> t_) /; StringLength[t] > 0] // TableForm
The paper we use for skew angle detection is: Skew detection and text line position determination in digitized documents by Gatos et. al. The only limitation with this paper is that it can detect skew upto -5 and +5 degrees. After that, we need something to slap the user with a message! :)
In your case, where there are primarily invoice scans, you may beautifully use: Multiresolution Analysis in Extraction of Reference Lines from Documents with Gray Level Background by Tag et. al.
We wrote the code in MATLAB, if you need help let me know!
I worked on a similar project once, and for being a long time user of OpenCV I ended up using it once again. OpenCV is a popular-cross-platform-computer-vision-library that offers programming interfaces for C and C++.
I found an interesting blog that had a post on how to detect the skew angle of a text using OpenCV, and then another on how to deskew.
To retrieve the text of the document and be able to pass a smaller image to tesseract, I suggest taking a look at the bounding box technique.
I don't know if the image acquisition procedure is your responsibility, but if it is you might want to take a look at how to do camera calibration with OpenCV to fix the distortion in the image caused by some camera lenses.