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

[Automatic pyramids levels fit] #13

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

floffy-f
Copy link
Contributor

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 from defaultParams and defaultParamsForm has not been taken out of the code, but I chose to put them at 1 just in case. No important effects on the code imho.

model.params

optiLevels =
getOptimumPyramids newLoaded
Copy link
Owner

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.

, 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
Copy link
Owner

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.

Copy link
Contributor Author

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.

@mpizenberg
Copy link
Owner

I've rebased your changes on the latest main. So now it should be easy to address some of the review comments I did without fear of more conflicts.

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
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

Successfully merging this pull request may close these issues.

2 participants