We're Hiring!

ROI Thumbnails

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

ROI Thumbnails

Postby mwicks23 » Wed Oct 31, 2018 2:02 pm

I have question about the OMERO APIs …

When I use the call “…/webgateway/render_roi_thumbnail/xxx/” I’m sometimes told the ROI is too large to generate a thumbnail – I’m returned an “Error Image”.
However, when I call “…/webgateway/render_image_region/51/0/0/?q=0.5&region=17196,16908,1680,1584” – being the coordinates of an actual ROI – this returns a large image, typically a screen full.

So my questions are these:
1. How can I predetermine whether a thumbnail of a ROI will be too large to be generated? (ie. Is it possible to know in advance somehow, when “render_roi_thumbnail” isn’t going to work?)
2. How can I generate a thumbnail of certain sub-area of an image? (ie. Can I scale down the returned image from “render_image_region”?)

Any suggestions gratefully received!
Mike W

PS. Some background;

I’m trying to evolve our Workbench, being grid of thumbnails of whole images, to become a grid of thumbnails of whole images, AND thumbnails of ROIs from the image selected for that cell. The Pathologist would typically like to see a grid of Tumours (ROIs) for easy comparison.
mwicks23
 
Posts: 7
Joined: Wed Oct 31, 2018 1:38 pm

Re: ROI Thumbnails

Postby jburel » Thu Nov 01, 2018 11:49 am

Dear Mike

1. render_roi_thumbnail
The logic is as follow: the method will try to render a region around the shape. The region is 1.5 x shape_width and 1.5 x shape_height. If the width or height of the region is greater than the omero.pixeldata.max_plane_width or omero.pixeldata.max_plane_height sets in the configuration value. It will fail to render. The default values are set at 3192.
The values can be retrieved using the configuration service.

2. render_image_region method returns a jpeg. so you can resize it using for example PIL.


I hope it helps

Jmarie
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: ROI Thumbnails

Postby mwicks23 » Fri Nov 02, 2018 3:33 pm

Thanks for this Jean-Marie - very helpful!

I have a follow-up about ROIs - is it possible via an API call to determine a "Bounding Box" around a ROI?
(In other words, what is the Rectangle that contains my Ellipse or Point ROI?)

For example, I have 3 ROIs:
1. POLYGON - Points "21063,15456 21581,15498 21987,15638 22337,15918 22435,16268 22197,16604 21875,16772 21385,16884 21021,16912 20531,16884 20139,16688 19929,16394 19915,16016 20097,15736 20419,15582 20783,15484"

2. RECTANGLE - Height 1584, Width 1680, Y 16908, X 17196

3. ELLIPSE - RadiusX 97.5, Y 22256.25, X 21180

Many thanks again
Mike W
mwicks23
 
Posts: 7
Joined: Wed Oct 31, 2018 1:38 pm

Re: ROI Thumbnails

Postby jburel » Mon Nov 05, 2018 12:57 pm

Hi Mike

There is no method currently that will return you the bounding box of a given shape.
That is certainly a feature to add.
Shapes can have Transforms associated to them so you will need to take that aspect into account when you calculate the Bounding Box.

Cheers

Jmarie
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: ROI Thumbnails

Postby mwicks23 » Mon Nov 05, 2018 1:23 pm

Thanks once again, Jean-Marie

MW
mwicks23
 
Posts: 7
Joined: Wed Oct 31, 2018 1:38 pm

Re: ROI Thumbnails

Postby pbankhead » Mon Nov 05, 2018 1:59 pm

As I understand it, 'render_roi_thumbnail' won't be reliable with whole slide images (like in this case) for which the annotated region could be extremely large in terms of pixel dimensions, at least in terms of the full resolution image.

Is there a straightfoward way to request pixels corresponding to the contents of the bounding box of any arbitrary ROI at a specified resolution (either specifying the scale factor or an integer resolution level)? Or specify a max width/height for the thumbnail, and have it rescaled accordingly?

It could be very handy if 'render_image_region' could take a specified scale factor as well (or can it already do so?).

Thanks,

Pete
pbankhead
 
Posts: 11
Joined: Sun Oct 09, 2016 5:19 pm

Re: ROI Thumbnails

Postby jburel » Tue Nov 06, 2018 12:22 pm

Dear Pete
you can specify the resolution and the region you which to render using render_image_region using
Code: Select all
data['tile'] = '1,0,0,512,512'

The first value is the resolution level, then the other 4 define x, y coordinates of the top-left corner and the width and height of the requested tile.
This should hopefully give you what you want

Below is the link to a test file showing various combinations
https://github.com/openmicroscopy/openm ... ndering.py


Cheers

Jmarie
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: ROI Thumbnails

Postby pbankhead » Wed Nov 07, 2018 11:36 am

Thanks! That looks like what I'd converged towards after checking the requests made when browsing an image in the OMERO viewer. I hadn't found any documentation for it or the sample code in your link.

As far as I could tell, the 'x' coordinate is defined in terms of the number of tile widths, and the 'y' coordinate the number of tile heights - not pixels. Also, at the far right/bottom of the image, it's important to put the ideal tile width/height used across the entire image into the request - and the result will simply come back truncated if it needs to be. Also, there's a hard-coded limit to the tile width/height ( I think 1024), and requesting any more would just result in a cropped tile being returned.

(This last point caused me a little pain, because previously I would always merge partial tiles with the preceding request, to ask for larger regions and avoid the risk of requesting a tile that was too thin to be returned when using other APIs).

Assuming I got it right in the end, this works fine for me in QuPath - although it took a while to realise what was going on. But it sounds like it would be challenging in Mike's example, where I understand the goal is to request an arbitrary downsampled region that doesn't map easily to tile boundaries (i.e. give x,y coordinates in pixel units, not tile units). I thought there might be an easier way that we'd missed, but if not then it helps already to know what the options are.

Thanks again,

Pete
pbankhead
 
Posts: 11
Joined: Sun Oct 09, 2016 5:19 pm

Re: ROI Thumbnails

Postby jburel » Thu Nov 08, 2018 1:08 pm

Hi Pete

To satisfy Mike's case, we will need to add support for new parameter if we want to specify the resolution.

Thanks for the report.
Cheers

Jmarie
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: ROI Thumbnails

Postby DaveMellert » Fri Jan 11, 2019 9:14 pm

Bumping this old thread because this is where I discovered render_image_region was possible! It seems like a largely undocumented feature, which has me wondering what else I am missing. Is this correct or am I looking in the wrong place (https://docs.openmicroscopy.org/omero/5 ... teway.html)?
DaveMellert
 
Posts: 21
Joined: Mon Jun 04, 2018 5:46 pm

Next

Return to Developer Discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron