I'm looking to create a survey program in Python that outputs the results of a series of questions into a few broad categories. As an example, I'm looking for something specifically along the lines of:
The idea is that the survey will give you a score between 3 and -3 and you lean towards one category or the other, depending on whether you scored positively or negatively.
Now, my idea is to manually use PIL to:
Iterate through appropriate category names and draw them
Draw the associated lines
Draw the rectangles according to score.
Also, it's worth mentioning that I'm trying to keep this as flexible as possible; we might add or remove categories at a later stage and I'd like to keep it so it would take minimal programming effort to do (as I likely will not be the one maintaining this in the future).
I suppose what my question would be is... does anyone know of any packages that might do this nicely? Or perhaps have any other suggestions or ideas? I didn't see anything suitable off of matplotlib. Admittedly, however, my expertise in graphing with Python is not extensive by any means!
Thanks for any ideas you might have!
Related
This question already has answers here:
Checking images for similarity with OpenCV
(6 answers)
Closed 8 years ago.
Setup is as follows:
Database with paintings
robot that takes shots of paintings
I want to compare the shots the robot made with the images in our database.
Problem is that the shots won't be perfect. The painting will most likely be IN the shot, but the shot will also contain wall/other objects. The incidence of light will also cause problems. Therefore I want to be finding images in the database that are similar to a certain degree.
I've been reading up on PIL, scipy, openCV, machine learning.
Is there anything you guys can recommend for this problem?
Thanks in advance.
edit: I'm aware of the solutions presented at other posts. Such as: comparing histograms/template matching and feature matching. Comparing histograms is not going to cut it in my application. Neither will feature matching. As it is to much of a workload. Template matching might, however the angles at which the shots will be taken won't be any near perfect.
You could use the SSIM index. There is a python implementation in scikit-image package.
Your problem sounds more like an application of feature detection and matching. Given a shot captured by the robot, you extract features from it, and compare them against the list of features you have in your database (each image having a lot of features). You might want to look at SURF, or some other descriptor that does your job. OpenCV has very well documented implementations for many variants. Feature matching would be the last stage where you actually make a decision about a match or a non-match.
Note that all of this is really heavy on processing, so forget real-time.
I have data about 10 points in a 2D map, I know the location of points 1,2 and 3. I also know the distance between point 1,2 and 3 to all other points.
I know that cell phone uses distance from gsm towers to locate their location. I wish to use similar approach to locate points 3-10. How can I implement such a solution with python? Which libraries can I use?
Thank you for all help
First, solve the math. Make a drawing. You will find that you can use two points and their distance to reduce the possible points to just two, the third one will only be needed to disambiguate between the two. Putting the whole into Python should be easy then.
Note that I'm not going to spell this out completely for you, because it is customary to not spoil other programmers the experience of doing their own homework, doing research etc. If you have something that you have a problem with, then ask specific questions and demonstrate some effort on your side first.
I'm interested in using python to make diagrams representing the size of values based on the size of squares (and optionally their colour). Basically I'm looking for a way to make overviews of a bunch of values like the good old program windirstat does with hard-drive usage (it basically makes a big square representing your harddrive and then smaller squares making up the area inside of it representing different programs, the bigger the square the larger the file, colour indicates the type of file). I'm fairly familiar with matplotlib, and I don't think it's possible to do something like this with it. Is there any other python package that would help? Any suggestions for something more low level if it's not? I guess I could do it manually if I could find a way to draw the boxes programatically (I don't really care about the format, but the option to export SVG as well as PNG would be nice).
Ultimately, it would be nice to have it be interactive like windirstat is, where if you were to hover over a particular square you get more information on it, and if you clicked on it maybe you'd go in and see the makeup of that particular square. I'm only familiar with wxpython for GUI stuff, not sure if it could be used for something like this. For now I'd be happy with just outputting them though.
Thanks a lot!
Alex
Edit:
Thanks guys, both your answers helped a lot.
You're looking for Treemapping algorithms. Once implemented, you can transform the output (which should be rectangles) into plotting commands to anything that can draw layered rectangles.
Edit:
More links and information:
If you don't mind reading papers, the browser-based d3 library provides for 'squarified' treemaps (js implementation). They reference this paper by Bruls, Huizing, and van Wijk. (This is also citation 3 on the wikipedia article)
I'd search on the algorithms listed on the linked Wikipedia article. For instance, they also link to this article, which describes an algorithm for "mixed treemaps". The paper also includes some interesting portions at the end describing transformations into other-than-rectangular shapes.
Squarified certainly appears to be the most common variety around. The above links should give you enough to work towards a solution or, even, directly port the d3 implementation. However, the cost of grokking d3's model (which is something like a declarative form of jQuery) may be somewhat high. At first glance, though, the implementation appears relatively straightforward.
Squaremap does this. I haven't used it (I only know it from RunSnakeRun) and its documentation is severely lacking, but it seems to work.
I'm working on a Minecraft-style game, and I need a way to reduce the amount of the world rendered. Currently, I'm using a naive, render-everything approach, which is having obvious scaling problems. I need a way to take an array of blocks, and in some way find out which ones are touching air, water, or any other translucent block.
I'm open to using external modules like NumPy or SciPy, though some of their documentation is a bit over my head. Alternatively, it would also be acceptable to iterate through each block and get a list of neighbors, though the performance cost of doing these calculations in Python instead of C would be pretty hefty.
For the record, I've already tried looking at NetworkX, but it seems to be more for scientific analysis or pathfinding than visibility checking.
If you only need to do this once, performance should not be an issue. If you also incrementally update the .isBoundary property of blocks whenever the world is changed, you will never have to do it again.
However you still run into issues if your world is too large or full of holes and caverns and transparent-interleaved-with-nontransparent. If you need to dynamically determine what is visible, you can keep an octree ( http://en.wikipedia.org/wiki/Octree ) where you can have giant expanses of air/water/etc. as a single node (giant block), labeled as "transparent". Then use the "paintbucket" algorithm (modified to perform Dijkstra's algorithm, so it is easy to detect when you've "gone around a corner" by checking to see if blocks exist between the current block and the origin) to quickly figure out which blocks are in sight. Updates for things far in the distance can be delayed significantly if the player is moving slowly.
You could use the Z-Buffer solution. Concerning speed, I'd write as much as possible in python and use pypy. EVE Online (a successful 3D MMO) was written in stackless python I believe.
After searching SO and multiple articles I haven't found a solution to my problem.
What I am trying to achieve is to load 20,000 markers on Google Maps.
R-Tree seems like a good approach but it's only helpful when searching for points within the visible part of the map. When the map is zoomed out it will return all of the points and...crash the browser.
There is also the problem with dragging the map and at the end of dragging re-running the query.
I would like to know how I can use R-Tree and be able to achieve the all of the above.
As noted, R-Tree won't help you when you're looking at a zoomed-out view. This problem is often addressed by marker clustering, because showing 20,000 points in a browser window isn't that useful.
Marker Manager is an open source javascript library which addresses this, but there are others.
With a very great number of markers, you may need to look at server-side clustering, (where R-Tree may come in handy!). Here is one discussion of it, and its google cache because link is dead at time of writing.
If you don't want to bother with clustering, then just terminate your marker list at a preset number, maybe a few hundred (which you can determine by usability testing), and display some indication that there are more available as you zoom in