[Automatic pyramids levels fit]#13
Conversation
| model.params | ||
|
|
||
| optiLevels = | ||
| getOptimumPyramids newLoaded |
There was a problem hiding this comment.
I'd suggest doing this the moment where we switch from the loading state to the state where all images are loaded so that this is done only once instead of each time one image is decoded.
| , Element.text ("(default to " ++ String.fromInt defaultParams.levels ++ ")") | ||
|
|
||
| -- , Element.text ("(default to " ++ String.fromInt defaultParams.levels ++ ")") | ||
| -- /!\ Default number of pyramids removed in order to put a fitting number of pyramids |
There was a problem hiding this comment.
Indeed it's not fixed anymore. Though once images are loaded, we could compute the default number of pyramid levels based on the images size and store that info inside the model so that we can display it here.
There was a problem hiding this comment.
Solution :
To solve this, I chose to store the default number of pyramids in the model directly.
It takes a little bit of memory, but I think it might be useful elsewhere (by that I mean not in the config tab) sometime.
This Int value is shown in the little text that I put back in the code.
To find its value, you have to look at model.paramsForm.defaultLevels, which is pretty convenient.
|
I've rebased your changes on the latest |
The optimum number of pyramids is only computed once, when all images are loaded
The default number of pyramids is stored in the model directly. It is then displayed in the little text of the config tab : "(defaults to x)"
elm-format applied for the branch auto-res
Automatic fil for the pyramids level
We want our images to go to a minimal resolution of 100x100px at the top of the pyramid.
Each level divides the resolution by two.
Let
be the height of the ith image, and
its width.
Then, let
and
.
Then the sequence of the steps of the pyramid for this minimal image is a geometric sequence, which writes :
and 
As we want a single n integer value for both height and width for all images, we choose the following formula :
.
The floor function helps us providing safety, avoiding to go further than 100 at the top stage of the pyramid.
For most good quality pictures, this corresponds to 4 levels. For minimal resolutions higher than
3200px, we have 5 of them.Lower than that, we usually have 2 or 3 levels.
The old
levelsfield fromdefaultParamsanddefaultParamsFormhas not been taken out of the code, but I chose to put them at1just in case. No important effects on the code imho.