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

Figure_To_Pdf: use max plane size to select the appropriate zoom level #553

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

sbesson
Copy link
Member

@sbesson sbesson commented Apr 19, 2024

The logic selecting the best resolution for the export can select a plane as large as omero.client.download_as.max_size. With a default value of 144000000, this means regions as wide as 12k x 12k can be requested to the server.

This commit proposes to use the max plane width and height instead to select the appropriate resolution level. Both configurations default to 3k and are already used for identifying an image as "big" and navigating through the resolution levels.

This PR should be tested by running the figure export workflow on a large pyramidal images. Adjust the zoom so that the width & height is in the 3k-10k range and run the figure export script.
The server logs should include the arguments passed to the rednderCompressed API e.g.

2024-04-19 11:34:23,564 INFO  [        ome.services.util.ServiceHandler] (rver-19469)  Meth:	interface omeis.providers.re.RenderingEngine.renderCompressed
2024-04-19 11:34:23,564 INFO  [        ome.services.util.ServiceHandler] (rver-19469)  Args:	[Type: XY, z=0, t=0; Region: x=19428 y=13901 width=7142 height=5110, renderShapes=false, shapeIds=[]]
2024-04-19 11:34:23,564 INFO  [             omeis.providers.re.Renderer] (rver-19469) Using: 'omeis.providers.re.HSBStrategy' rendering strategy.

With this change included, using the same OMERO.figure configuration, the export script should select a smaller resolution level with width and height both being smaller than 3k by default e.g.

2024-04-19 11:34:59,931 INFO  [        ome.services.util.ServiceHandler] (rver-19467)  Meth:	interface omeis.providers.re.RenderingEngine.renderCompressed
2024-04-19 11:34:59,931 INFO  [        ome.services.util.ServiceHandler] (rver-19467)  Args:	[Type: XY, z=0, t=0; Region: x=4857 y=3475 width=1785 height=1277, renderShapes=false, shapeIds=[]]
2024-04-19 11:34:59,931 INFO  [             omeis.providers.re.Renderer] (rver-19467) Using: 'omeis.providers.re.HSBStrategy' rendering strategy.

As a side-effect, this significantly reduces the size of the exported PDF

The logic selecting the best resolution for the export can select a
plane as large as omero.client.download_as.max_size. With a default value
of  144000000, this means regions as wide as 12k x 12k can be requested
to the server.

This commit proposes to use the max plane width and height instead to
select the appropriate resolution level. Both configurations default to
3k and are already used for identifying an image as "big" and navigating
through the resolution levels.

# start big, and go until we reach target size
zm = 0
while (zm < max_level and
zm_levels[zm] * width > max_width or
zm_levels[zm] * width * zm_levels[zm] * height > max_plane):
zm_levels[zm] * width > max_sizes[0] or
zm_levels[zm] * height > max_sizes[1]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By comparing width and height separately you get a more conservative (smaller) image, E.g. if your image width is 3 x the height, then the plane size you get will be 1/3 of the big image cut-off.

Alternatively you could leave this logic unchanged and do max_plane = max_sizes[0] * max_sizes[1] above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7d25b9f. This is consistent with the way plane sizes are used in is_big_image above

def is_big_image(self, image):
"""Return True if this is a 'big' tiled image."""
max_w, max_h = self.conn.getMaxPlaneSize()
return image.getSizeX() * image.getSizeY() > max_w * max_h

but also server-side to indicate the requirement of pyramidal levels

https://github.com/ome/omero-romio/blob/1d30fafc4e06c5511cfbb24c25a753925ffb2eb4/src/main/java/ome/io/nio/PixelsService.java#L686

Copy link
Member

@will-moore will-moore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks 👍

@will-moore
Copy link
Member

Tested locally, exporting a figure containing big SVS image panels at various zoom levels, using the export to "PDF and Images" to generate a zip containing the original rendered images.
All images were the same size testing with/without this PR except where the image was over 3k x 3k.
E.g. without this PR an image was exported at 6062 × 2853 pixels, but with this PR it was 3031 × 1426.

@will-moore will-moore merged commit d623d03 into ome:master Apr 26, 2024
1 check passed
@sbesson sbesson deleted the max_plane_fix branch April 26, 2024 12:10
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