Page 2 of 2

Re: Permanent Programming #6

PostPosted: Sun Apr 05, 2009 12:14 pm
by Chaosmaster
Hmm, the cropping, analyzing and getting the answer part is quite fast.
I am using imagemagick to do the rotations and I just can't think of anything to speed it up,
I suppose i could scale down the images before rotating, but this way i would loose image quality.

Re: Permanent Programming #6

PostPosted: Mon Apr 06, 2009 9:21 am
by Defience
Chaosmaster wrote:I wan't asking it it was possible in another language, I was asking if there's a way to speed it up in php.
Why would you need 36 rotations anyway? I only need 8, but it still takes too long.


It's actually 1 complete rotation but at 10 degrees for each row. If you set a crop for the row at the 12 O'clock position and then rotate the image 10 degrees it should line up the very next row into the crop that's been set. Doing this for each row will achieve 360 degrees. You could also disable javascript which would give you a few more seconds so you don't have to go through the 25% done, 50% done, etc....

Re: Permanent Programming #6

PostPosted: Mon Apr 06, 2009 10:42 am
by Chaosmaster
Defience wrote:
Chaosmaster wrote:I wan't asking it it was possible in another language, I was asking if there's a way to speed it up in php.
Why would you need 36 rotations anyway? I only need 8, but it still takes too long.


It's actually 1 complete rotation but at 10 degrees for each row. If you set a crop for the row at the 12 O'clock position and then rotate the image 10 degrees it should line up the very next row into the crop that's been set. Doing this for each row will achieve 360 degrees. You could also disable javascript which would give you a few more seconds so you don't have to go through the 25% done, 50% done, etc....


I actually am using GD to draw the initial image. And then i need 8 rotations by 10 degrees and i can crop out the 12,3,6,9 o'clock positions, then i only need to rotate 3/4 of the chars by 90,180,270 degrees respectively (no interpolations are needed and the single chars are much smaller).
My problem only are the 8 major rotations which consume too much time.

Re: Permanent Programming #6

PostPosted: Fri May 01, 2009 5:22 pm
by DrakierD
Edit:
Nevermind.. I found my issue and solved the problem

Re: Permanent Programming #6

PostPosted: Sun Jul 05, 2009 9:19 pm
by Baggins
Chaosmaster wrote:I actually am using GD to draw the initial image. And then i need 8 rotations by 10 degrees and i can crop out the 12,3,6,9 o'clock positions, then i only need to rotate 3/4 of the chars by 90,180,270 degrees respectively (no interpolations are needed and the single chars are much smaller).
My problem only are the 8 major rotations which consume too much time.

Using GD the same 8 rotations only take me about 6 seconds.

Re: Permanent Programming #6

PostPosted: Mon Jul 06, 2009 5:14 am
by Nines
Just for the record.. For those saying it takes too much time to rotate the image, are you acually displaying the rotated image each time?

Re: Permanent Programming #6

PostPosted: Wed Jul 29, 2009 8:26 pm
by jpmut
I used the OCR approach with Java, n it worked pretty fast! however, it takes time to fine-tune the program! i did the pixel-counting first, but it didn't work well! the hardest part was finding the center, after realizing how hard it is to program it, i chose to find it manually. i would view the image, select the center, then the program would do the rest! it did 35 rotations n found the letters in less than 2 sec, what took time was selecting the correct center.

Re: Permanent Programming #6

PostPosted: Thu Jul 30, 2009 10:29 am
by Defience
Yes, its important to note that the center of the page is not the center of the spiral.

Re: Permanent Programming #6

PostPosted: Thu Aug 20, 2009 1:41 pm
by mancontr
I solved it with Python without using the image, but the data embedded in the Javascript code.
The drawing method is the same as in programming 4, so I extracted the lines and arcs from the source, organized them in letters (this is the hardest part), and then identified the letter by line counting ("B" is 4 lines and 2 arcs, "8" is 2 arcs,...) and some other simple heuristics.
This method is a lot faster than using the picture (no rotations, mine runs in 0.1s) and has better accuracy (it can't mistake a B for an 8, but the OCR do). But it may be somewhat harder to find out which line belongs to which letter.
Drawing the lines between letters before starting to code may help you think some strategy.
Good luck everyone!