codebox / mosaic

Python script for creating photomosaic images
https://codebox.net/pages/photo-mosaic-image-maker
MIT License
537 stars 166 forks source link

Possible to limit number of time a tile is used ? #1

Closed ludov04 closed 8 years ago

ludov04 commented 9 years ago

Hi, your tool seems very useful, I have one simple question:

Is it possible to limit the number of time a tile is used ? If yes, how can it be achieved ? If no, is it easily implementable, any idea how to implement it ?

Thank you .

codebox commented 9 years ago

Hi, There is no way to do this at the moment, but it shouldn't be too difficult to achieve. If you make a change to the TileFitter class to keep a count of how many times each tile gets used, and then remove any tile that gets used more than a certain number of times that should give you what you need. Rob

On 8 January 2015 at 13:13, ludov04 notifications@github.com wrote:

Hi, your tools seems very useful, I have one simple questions:

Is it possible to limit the number of time a tile is used ? If yes, how can it be achieved ? If no, is it easily implementable, any idea how to implement it ?

Thank you .

— Reply to this email directly or view it on GitHub https://github.com/codebox/mosaic/issues/1.

ludov04 commented 9 years ago

Ok great, I'll try that. Another question: I'm not familiar with multiprocessing in python, but as I understand, there is one instance of TileFitter per worker. So if I really want an absolute limit, I have to create some shared state across thoses instances to keep count of how many times a tile gets used. Am I right ? Is there another solution to avoid shared state, as it is not really recommended ? Ludovic

codebox commented 9 years ago

Yes, that's correct you get one TileFitter per worker - I would suggest giving a limit to each TileFitter individually rather than having one shared limit value, eg if you are using 4 CPU cores and want each tile to be used at most 100 times set the limit for each TileFitter to be 25.

On 10 January 2015 at 11:49, Ludovic Vannoorenberghe < notifications@github.com> wrote:

Ok great, I'll try that. Another question: I'm not familiar with multiprocessing in python, but as I understand, there is one instance of TileFitter per worker. So if I really want an absolute limit, I have to create some shared state across thoses instances to keep count of how many times a tile gets used. Am I right ? Is there another solution to avoid shared state, as it is not really recommended ? Ludovic

— Reply to this email directly or view it on GitHub https://github.com/codebox/mosaic/issues/1#issuecomment-69453196.