Out-of-bounds ROI creation
Posted: Tue Aug 09, 2011 11:50 am
Hi,
I have been using Insight to create ROIs on my images and then use the 'Util scripts/Images_From_ROIs' script to extract new images.
This is find when the ROI is within the image. However in Insight it is possible to create an ROI that goes out of the bounds of the image by dragging the rectangle too far when creating the ROI. When I run the script I get an error like this:
I have fixed this by adding a simple boundary check to the ROI dimensions:
However I wanted to know if it is a bug that ROIs can be outside the dimensions of the image.
I am using OMERO 4.3.0.
Regards,
Alex
I have been using Insight to create ROIs on my images and then use the 'Util scripts/Images_From_ROIs' script to extract new images.
This is find when the ROI is within the image. However in Insight it is possible to create an ROI that goes out of the bounds of the image by dragging the rectangle too far when creating the ROI. When I run the script I get an error like this:
- Code: Select all
ERROR:blitz_gateway:Failed to getPlane() or getTile() from rawPixelsStore
Traceback (most recent call last):
File "/home/omero/omero_dist/lib/python/omero/gateway/__init__.py", line 4579, in getTiles
rawPlane = rawPixelsStore.getTile(z, c, t, x, y, width, height)
File "/home/omero/omero_dist/lib/python/omero/gateway/__init__.py", line 2943, in wrapped
return inner(*args, **kwargs)
File "/home/omero/omero_dist/lib/python/omero/gateway/__init__.py", line 2885, in inner
return f(*args, **kwargs)
File "/home/omero/omero_dist/lib/python/omero_api_RawPixelsStore_ice.py", line 182, in getTile
return _M_omero.api.RawPixelsStore._op_getTile.invoke(self, ((z, c, t, x, y, w, h), _ctx))
ApiUsageException: exception ::omero::ApiUsageException
{
serverStackTrace = ome.conditions.ApiUsageException: X '320' greater than sizeX '256'.
...
I have fixed this by adding a simple boundary check to the ROI dimensions:
- Code: Select all
W = image.getSizeX()
H = image.getSizeY()
...
for index, r in enumerate(rois):
x,y,w,h, z1,z2,t1,t2 = r
# Bounding box
if x < 0: x = 0
if y < 0: y = 0
if x + w > W: w = W - x
if y + h > H: h = H - y
However I wanted to know if it is a bug that ROIs can be outside the dimensions of the image.
I am using OMERO 4.3.0.
Regards,
Alex