I've learned to never underestimate what PHP and some libraries can do, so for this paper effect, can it be done with a php graphics library (or at least programmatically) without needing something like Photoshop or Illustrator?
To be clear, I'm asking just about the paper, not the iphone.
Edit: Dan Grossman's answer is great. I'm also wondering if someone can give me algorithmic ideas what might be happening in this image so I could try to possibly come up with some code to map it mathematically. My visual imagination is failing me a little.
The answer is always yes, it's just a matter of difficulty/complexity.
PHP is a Turing-complete language, which means it has equal capabilities of every other Turing-complete language, like C++/Java or whatever your photo editing program was written in.
That means whatever Photoshop does, you can do. If nobody has written a handy library, you can treat the image as a matrix and perform the mathematics necessary to get the desired warping, then write the resulting matrix of pixel information to a new image one pixel at a time as a bitmap.
Of course you weren't hoping for that answer, you meant "does someone provide an easy library for PHP to do effects like this with a couple prewritten commands", right?
That's a little much for PHP's GD library, but you can always shell out to a command line image processor, like imagemagick, and read the resulting file to send back to the browser.
Imagemagick has plenty of distortion methods which will help you get to where you want. However with the detail you've given you'll need to do the math yourself to work out the correct combination of distortions to get the page curl you're after
Related
I'm trying to read scanned qr codes from php, running zbarimg via exec. Working not-too-bad.
The issue is that it seems to choke on scanning artifacts like these small dots:
I've been trying to get rid of the white dots syndrome by fiddling around with Imagick - changing brightness/contrast/sharpness seems to make them stand out less but some, like this one, are still unreadable.
Is there a way to remove the white dots / improve zbarimg's recognition?
Edit:
One thing I forgot to point out:
What strikes me as weird is the fact that scanning the QR via smartphone, using the camera, reads the code succesfully in a single instant without a single issue, which leads me to think this "fixing up" shouldn't even be needed.
Am I just using zbar the wrong way?
Or do mobile OSes just use a different, better, algorithm? I tried using a zxing wrapper for PHP as well, but it gave even less results compared to zbar.
In terms of cleaning up the image you have shown us, the obvious approach would be to use cellular automata - although for best results you would ant to modify the behaviour to encompass the sharpening and thresholding you are already applying using other filters. You might consider setting the size of the cell to, say, one 25th of the QR code block resolution rather than a 1:1 with pixels in the unerdlying image. Really you should be applying your thresholding via a histogram based approach (assuming that you can isolate the QR code in the image).
I'm not aware of an implementation in PHP but there is at least one OpenCV interface for PHP
What is the best way in PHP to determine if a PDF is filled out correctly? The source PDF is a faxed form that contains handwritten data. Is an image comparison an option? If the form is filled out on a computer, I know I can use pdftotext to verify that the fields are completed or not. I just don't know how to verify handwritten data.
For hand-written data an image comparison may definitely be an option. See for example the following answer for a basic idea how to start tackling this task:
Imagemagick : “Diff” an Image
However, the job may be much more difficult when faxed images come into play. (We all know how bad a quality you can get from faxes. Also, they frequently are skewed by a small degree. And they may be slightly scaled, compared to the original. Not to forget that their resolution is 204x196dpi, which adds a bit of a distortion. And lastly -- how do you get the faxed form back into PHP? This might involve another step of scanning in the paper, which again will not necessarily add quality to the result.
Still, ImageMagick may be able to handle all this: it can -deskew images, it can reduce or completly remove -noise, and it can -distort, -scale and -repage images and much more...
Is there some kind of software that I can feed uploaded images to and have it process them to give back to me? This question is based off of this question, where one of the answerers told me to use some kind of processor that I could feed images to, but he did not know one that was good. Are there any programs like this?
PHP has GD built in. Check out some of the functions in that link. Hope this is what you're looking for.
As Jebego said, GD is good and will do almost all of what you could possibly need.
And ImageMagick does everything that you could possibly need, but is slightly harder to use.
However I think the answer to your other question is bogus, and possibly leading you down the wrong path.
I'm trying to create a mosaic type script in Javascript and PHP, which makes up a big image with many different images made from small square tiles. The idea was to "fake" the effect by having a background image and laying over the tiles on top of it, and making their opacity 50% or so. This works decently enough, but it definitely doesn't look as good as I want.
My question is, does anyone have any recommendations on alternatives to this method? I know there are definitely ways to do this in Flash, such as the Mario Lemieux mosaic:
http://www.mariomosaic.com/mosaic/
But I would like to avoid flash if possible.
edit: added live example
So I haven't touched the JS layer yet, this has all been server-side stuff. There's no pre-loader or anything really in terms of making it more usable, that will come soon. But here's what I've got so far:
http://www.mtimofiiv.net/mosaic_example/
The little tiny image tiles are created from images uploaded by a user, and they're run through a class I've built to generate them. I used GD2 to make them grayscale so they will absorb the color of the background image better, and I "pixelated" the background image in Photoshop.
If anyone wants to see any part of the code let me know and I'll add it to this post. Also when this project's done I intend to make it available on Github in its entirety for whoever wants to do the same.
Perhaps the fact that your demo HTML is 733KB might dissuade you from this particular approach. I think if you want to do something like this, you really ought to employ the canvas element, and work in some kind of "ajax" loading. That could actually be kind of interesting. However, if you are going to generate this much HTML...you might consider having a client-side script do it, if possible. Just some thoughts...
I am looking to generate transport maps in a style similar to the iconic London underground [tube] map.
These maps will change from time to time and many will be required so instead of drawing them up manually in inkscape [or similar] I am hoping to have them generated dynamically from a db or dataset.
Does anyone know if there is any library apis etc. out there that would help with this task, or any suggestions in general of how [or how not] to go about this ?
I am thinking svg's would be the best way to go with this, plus there may be need for basic interactivity down the line.
I am working in php so otherwise it's GDlib, ImageMagick ?
Thanks in advance.
.k
Well, the answer really isnt in how to use GD or ImageMagick, there are manuals for that. As for helper libraries, most libraries focus on graphing, anything else you will have to write yourself. Your best bet as a solution would be to have your admin interface generate the images when data in the backend changes and cache the images, since there's no reason to build the image every time someone accesses it.
For generating maps, i think your best bet would be defining stations with one or many 'lines' which determine some sort of indicator of relationship to the stations around, and an x,y. You'd probably only need to determine a 'parent' station since you're just drawing lines from a-b. That way you can position them in the same manner as they're typically rendered on the actual trains, use the lines and surrounding stations to draw mappings.
Doesn't sound like too difficult a problem. 3 tables:
stations [stationid,name,x,y,meta1,meta2],
placements [placementid,stationid,lineid,parentstationid],
lines [lineid,name,meta1,meta2,colour,etc].
SVG would be pretty good at this sort of thing, and you would avoid the whole image building and caching process, but be wary of browser support issues.
Sounds like a pretty interesting project though, good luck :)
One strategy I use when I need to generate graphs from data in a db is to extract the data in some kind of XML way (e.g. Oracle SQLX or Cocoon XSP/ESQL or eXist-db XQuery) and process it through an XSLT to generate SVG. Good old Cocoon is fine for this kind of job if you don't want to write any code (except the XSL of course ;-).
The SVG itself can be loaded in some graphic tools to reprocess.
These maps will change from time to
time and many will be required so
instead of drawing them up manually in
inkscape [or similar] I am hoping to
have them generated dynamically from a
db or dataset.
If I were in your shoes, the very first thing I'd do is try to prove that the Google Maps API won't work for your application. Then, maybe, prove that ArcGIS won't work. (Even if they don't work, they're widely used, and you get to add lines to your CV.)