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

Dynamic Downsampling #25

Open
Tracked by #39
THEGOLDENPRO opened this issue Nov 5, 2024 · 2 comments
Open
Tracked by #39

Dynamic Downsampling #25

THEGOLDENPRO opened this issue Nov 5, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@THEGOLDENPRO
Copy link
Member

THEGOLDENPRO commented Nov 5, 2024

At the moment images are downsampled to around display resolution on image load so for example if we have an image that is 3840 x 2160 (4k) getting loaded but our display / monitor is only 1080p, roseate will automatically downsample that image to 1920x1080 (plus some extra pixels).

This is great until we start zooming into the image and notice all the clarity we have lost, so let's dynamically adjust the downsampling when the user zooms in/out.

However this will need to be done in the background hence we will need #24 to be completed first.

@THEGOLDENPRO THEGOLDENPRO added the enhancement New feature or request label Nov 5, 2024
@THEGOLDENPRO THEGOLDENPRO self-assigned this Nov 5, 2024
@THEGOLDENPRO THEGOLDENPRO changed the title Dynamic Scaling Dynamic Downsampling Nov 17, 2024
@THEGOLDENPRO
Copy link
Member Author

Now that downsampling is multi-threaded this feature can begin to be implemented.

@THEGOLDENPRO
Copy link
Member Author

This is just my notes so good luck reading it.🤞

Every time the user zooms in, we upsample the image to a resolution equal to:

image_res x zoom_scale_factor

but the upsample resolution cannot exceed the original resolution of the image, essentially setting a cap.

The image should only upsample / downsample once the user is done zooming in / out (more info below) and we should only have one of these operations going on at a time but we should also cancel an ongoing operation or a scheduled one if we have to schedule a new upsample / downsample operation.

Also when zooming out the downsample should be scheduled a lot later than the upsample in the case the user would like to zoom in again for one quick glimpse. We only downsample in the first place to save on memory when detail is not important and also so high res images aren't overly sharpened.

It's all about user experience and efficiency.

reload image mechanism

Right now if we were to implement this we would be calling Image.load_image() many many times and Image.load_image() is not designed to be ran many many times as if that function is executed while the image is already loaded it will do a full complete image reload (re-reading bytes from the file and etc) when it's unnecessarily as the bytes would have already existed in memory via Image.image_bytes.

We need a new function like Image.reload_image() to handle cases as such below:

  • We want to downsample an already loaded image, the image bytes already exist so we should use them instead of reading from the file again.
  • We want to upsample an existing image that has already been downsampled, in this case we don't have the bytes in memory necessary to upsample so we'll have to read the entire file again and load that.

config

WIP is my brain, I'll think about it after implementation of some of this.

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

When branches are created from issues, their pull requests are automatically linked.

1 participant