-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Automatic pyramids levels fit] #13
base: main
Are you sure you want to change the base?
Conversation
web-elm/src/Main.elm
Outdated
model.params | ||
|
||
optiLevels = | ||
getOptimumPyramids newLoaded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
web-elm/src/Main.elm
Outdated
, 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
levels
field fromdefaultParams
anddefaultParamsForm
has not been taken out of the code, but I chose to put them at1
just in case. No important effects on the code imho.