Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimizations #1

Open
Estevo-Aleixo opened this issue Jun 23, 2015 · 4 comments
Open

optimizations #1

Estevo-Aleixo opened this issue Jun 23, 2015 · 4 comments

Comments

@Estevo-Aleixo
Copy link

How would I change the image comparison to only look at the bounding box of the change in the generated image and the mona image? Something like UIRectClip ( CGRect rect ); ?

Instead of choosing the color before comparison why not make the comparison/iteration return the average color of the bounding box? (or of the center vertical and horizontal line) Including another comparison to the image would make it a 2n problem (without the optimization of the center vert/horiz line), but would this comparison be useful?

@qarl
Copy link
Owner

qarl commented Jun 23, 2015

i think both of those ideas would significantly speed up the convergence. as it is, the current code is not optimized for speed - it's optimized for simplicity.

in the first case, you'd have to be careful: the score for one bounding box would be different than for another bounding box. so you couldn't just keep last iteration's score and compare against that - you'd need to recompute the previous image's score for each new bounding box.

@Estevo-Aleixo
Copy link
Author

Would making the generated image the same size as the mona image remove the need for every compare to resize both images? (I am not an objective-c programmer, and I do not know the API well enough yet) (or whichever is bigger between the mona image and the canvas)

This may be a bug, but if the pixel is three color channels mixed into one representation of a pixel is it correct to do a abs(505152 - 006000) ? where the red channel is 0x50 green is 0x51 blue is 0x52. Would an XOR be a better representation of the difference in channels?

@qarl
Copy link
Owner

qarl commented Jun 24, 2015

yup. resizing the Mona image for every comparison is very wasteful, time-wise. :)

@Estevo-Aleixo
Copy link
Author

The decision and change idea (without the xor for separating color channels)

cur_score = mona_score - (mona_aabb_score - change_aabb_score)
if cur_score > mona_score:
    paint()
    mona_score = cur_score

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants