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

Use script on other shapes #209

Open
lguerard opened this issue Jul 6, 2023 · 3 comments
Open

Use script on other shapes #209

lguerard opened this issue Jul 6, 2023 · 3 comments

Comments

@lguerard
Copy link

lguerard commented Jul 6, 2023

Hi all !

I wanted to the use the Images_From_ROIs script to crop my images on our OMERO, but was surprised to see that this is limited to rectangles as shown here:

if type(shape) == omero.model.RectangleI:

I wanted to modify it to accept all types of shapes but couldn't find anything about getting the bounding box for any other shape, did I miss something ?

Thanks for your help !

@will-moore
Copy link
Member

I'm afraid you'll need to handle each Shape separately.
Create a function, e.g. getBoundingBox(shape) and implement that for each type of Shape.
E.g. for PolyLine or Polygon, iterate through all the points and find min/max for X and Y.
See https://omero.readthedocs.io/en/v5.6.7/developers/Python.html#rois under "Retrieve ROIs linked to an Image"
For polygons and polyline parsing of the points string, see https://github.com/ome/omero-web/blob/ba072f151247df5b62768a0fbf37891675e2802d/omeroweb/webgateway/marshal.py#L390

@lguerard
Copy link
Author

lguerard commented Jul 7, 2023

Thanks @will-moore for the pointers. Stupidly enough, I thought that it would be a simple getbbox like in Fiji. When I have time I'll look at implementing it !

In the meantime, I've also noticed that using the script on a 16bit image returns an 8bit image. Also the thumbnail looks weird and the image doesn't open, would you know why this would happen ?
image

@will-moore
Copy link
Member

I'm not sure what you're seeing there but the script works for me on a 16-bit image so I'm not sure it's the data-type.
Can you test with a few different images and confirm whether you're seeing this issue on all 16-bit images but not on any others?

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

2 participants