Permanent Programming #6

Put your programming skills to the test in these challenges.

Re: Permanent Programming #6

Post by Chaosmaster on Sun Apr 05, 2009 12:14 pm
([msg=21192]see Re: Permanent Programming #6[/msg])

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.
Chaosmaster
New User
New User
 
Posts: 4
Joined: Wed Feb 25, 2009 3:58 am
Blog: View Blog (0)


Re: Permanent Programming #6

Post by Defience on Mon Apr 06, 2009 9:21 am
([msg=21291]see Re: Permanent Programming #6[/msg])

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....
User avatar
Defience
Addict
Addict
 
Posts: 1281
Joined: Thu Jun 12, 2008 3:16 pm
Blog: View Blog (0)


Re: Permanent Programming #6

Post by Chaosmaster on Mon Apr 06, 2009 10:42 am
([msg=21298]see Re: Permanent Programming #6[/msg])

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.
Chaosmaster
New User
New User
 
Posts: 4
Joined: Wed Feb 25, 2009 3:58 am
Blog: View Blog (0)


Re: Permanent Programming #6

Post by DrakierD on Fri May 01, 2009 5:22 pm
([msg=22963]see Re: Permanent Programming #6[/msg])

Edit:
Nevermind.. I found my issue and solved the problem
DrakierD
Experienced User
Experienced User
 
Posts: 51
Joined: Tue Apr 07, 2009 2:14 pm
Blog: View Blog (0)


Re: Permanent Programming #6

Post by Baggins on Sun Jul 05, 2009 9:19 pm
([msg=26281]see Re: Permanent Programming #6[/msg])

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.
Baggins
New User
New User
 
Posts: 1
Joined: Mon Jun 29, 2009 11:38 am
Blog: View Blog (0)


Re: Permanent Programming #6

Post by Nines on Mon Jul 06, 2009 5:14 am
([msg=26293]see Re: Permanent Programming #6[/msg])

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?
User avatar
Nines
Poster
Poster
 
Posts: 191
Joined: Sun Apr 13, 2008 5:57 pm
Blog: View Blog (0)


Re: Permanent Programming #6

Post by jpmut on Wed Jul 29, 2009 8:26 pm
([msg=27645]see Re: Permanent Programming #6[/msg])

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.
The philosopher and mathematician Bertrand Russell was asked, "If a false premise can imply any conclusion, use 1 = 2 to prove you're the Pope!" Russell replied, "The Pope and I are two, so we are one."
User avatar
jpmut
New User
New User
 
Posts: 22
Joined: Fri Jul 03, 2009 1:13 pm
Blog: View Blog (0)


Re: Permanent Programming #6

Post by Defience on Thu Jul 30, 2009 10:29 am
([msg=27663]see Re: Permanent Programming #6[/msg])

Yes, its important to note that the center of the page is not the center of the spiral.
User avatar
Defience
Addict
Addict
 
Posts: 1281
Joined: Thu Jun 12, 2008 3:16 pm
Blog: View Blog (0)


Re: Permanent Programming #6

Post by mancontr on Thu Aug 20, 2009 1:41 pm
([msg=28198]see Re: Permanent Programming #6[/msg])

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!
mancontr
New User
New User
 
Posts: 1
Joined: Sat May 23, 2009 1:35 pm
Blog: View Blog (0)


Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests