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

Determine donwsample_img automatically #51

Open
jankrepl opened this issue Aug 17, 2021 · 0 comments
Open

Determine donwsample_img automatically #51

jankrepl opened this issue Aug 17, 2021 · 0 comments

Comments

@jankrepl
Copy link
Contributor

jankrepl commented Aug 17, 2021

In download_parallel_dataset one can specify both the downsample_ref and downsample_img manually. However,
it might be very useful to imply a reasonable downsample_img from the selected downsample_ref and the resolution of a given image (can be found in the API metadata).

Intuitively, the following should be true to avoid artifacts in the synchronized image

img_shape / (2 ** downsample_img) > refspace_shape / downsample_ref

At the same time, we want the downsample_img to be as large as possible to make the download fast + avoid wasting disk space.

So specifically let's take a section image id = 101349501. It comes from a coronal dataset and has a shape of (4344, 5096). As usually, we set downsample_ref to 25.

Therefore

refspace_shape = (8000, 11400)
downsample_ref = 25

img_shape = (4344, 5096)
downsample_img = x  # we want to solve for this and it must be an integer

Just using the above unequality one proposition could be

downsample_img < log_2((min(img_shape) * downsample_ref) / max(refspace_shape)))

So the below formula could work?

int(np.log2((min(img_shape) * downsample_ref) / max(refspace_shape)))
3

I checked the synchronized image and there seem to be no artifacts.

Finally, we should be also careful about downsample_img being too high because the image download API does not support high values.

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

No branches or pull requests

1 participant