Page 1 of 1

rectangle Font size

PostPosted: Tue Jun 16, 2015 4:25 pm
by Olivier Debeir
Hi,
here is a piece of code to add ROIs into Omero DB from a python script (server side)
I was wondering if it is possible to increase the fontSize of the rectangle label
(is there an example that uses fontSize or something ?)
moreover, since this annotation is placed inside a big-image, I was wondering if there is a way to set the fontsize independant of the zoom level in the client (the default size is way to small when dealing with whole slide imaging...)?

Thanks !

Olivier


Code: Select all
         
                   # create a rectangle shape and add to ROI
                    rect = omero.model.RectI()
                    rect.x = rdouble(x)
                    rect.y = rdouble(y)
                    rect.width = rdouble(width)
                    rect.height = rdouble(height)
                    rect.theZ = rint(theZ)
                    rect.theT = rint(theT)
                    rect.textValue = rstring(str(core_id))
                    rect.strokeColor = rint(0xff0000)
                    roi.addShape(rect)


[edited]

the following lines seems to do the job
Code: Select all
fontSize = LengthI()
fontSize.setValue(1000)
fontSize.setUnit(UnitsLength.POINT)
rect.setFontSize(fontSize)


However, the Java client does not appreciate these ROIs (Cannot display the ROI)...
maybe a version issue here ?

Re: rectangle Font size

PostPosted: Wed Jun 17, 2015 1:01 pm
by jburel
Hi Olivier
I reckon you have a ROI with multiple shapes on the same plane.
The ROI tool in the Desktop client does not support it.
This is a known limitation.
If you wish to have shapes on the same plane, you will have to create a ROI per shape.

Cheers
Jmarie

Re: rectangle Font size

PostPosted: Wed Jun 17, 2015 2:52 pm
by Olivier Debeir
actually, each roi contains only one shape (a rect)

here is the complete code
(cores in basically a dict containing coordinates),
the problem occurs when I try to set some attributes(stroke width and font size) for the shape object

Code: Select all
                core_ids = sorted(cores.keys())

                for core_id in core_ids:
                    core = cores[core_id]

                    # add one new rectangle ROI
                    x = min(core['bb_x0'],core['bb_x1'])
                    y = min(core['bb_y0'],core['bb_y1'])
                    width = abs(core['bb_x1']-core['bb_x0'])
                    height = abs(core['bb_y1']-core['bb_y0'])
                    theZ = 0
                    theT = 0

                    # create an ROI, link it to Image
                    roi = omero.model.RoiI()

                    # use the omero.model.ImageI that underlies the 'image' wrapper
                    roi.setImage(image._obj)

                    # create a rectangle shape and add to ROI
                    rect = omero.model.RectI()
                    rect.x = rdouble(x)
                    rect.y = rdouble(y)
                    rect.width = rdouble(width)
                    rect.height = rdouble(height)
                    rect.theZ = rint(theZ)
                    rect.theT = rint(theT)
                    rect.textValue = rstring(str(core_id))

                    ## problem occurs in java client 5.1.2 Ice35 b45,
                    ## when the following lines are uncommented,
                    ## web viewer is ok
                    #rect.strokeColor = rint(0xff0000)   
                    #rect.setStrokeWidth(strokeWidth)
                    #rect.setFontSize(fontSize)           

                    roi.addShape(rect)

                    # Save the ROI (saves any linked shapes too)
                    r = updateService.saveAndReturnObject(roi)


[edited]
in fact the version without the lines display the roi fugaciously, once I move the mouse, they disappear, hence they remain selectable.

Re: rectangle Font size

PostPosted: Thu Jun 18, 2015 11:56 am
by wmoore
I have repeated the problems you're seeing with display of these shapes in Insight and created a ticket: http://trac.openmicroscopy.org/ome/atta ... ket/12936/

I set the sizes like this, although this does seem kinda painful to me!
Code: Select all
    strokeWidth = omero.model.LengthI(5, UnitsLength.PIXEL)
    rect.strokeWidth = strokeWidth
    fontSize = omero.model.LengthI(50, UnitsLength.PIXEL)
    rect.fontSize = fontSize


I'm not sure I see any fugacious shapes that disappear with mouse movement?
If I don't set the fontSize then the shapes show up in Insight, but stroke width is ignored.
What do you mean "without the lines"?

The idea of a "zoomable" attribute on font-size is an interesting one.
We have certainly grappled with the issue of displaying font & shapes at useful sizes while zooming big images.
We'll give it some consideration.

Thanks

Re: rectangle Font size

PostPosted: Thu Jun 18, 2015 1:57 pm
by Olivier Debeir
('without the line' that are in comment in the code)
I guess the problem of displaying a lot of rois is maybe linked to my client/os (ubuntu), I will try on MacOSx version...

thanks for the hint for strokeWidth and fontSize,

regards,
Olivier

Re: rectangle Font size

PostPosted: Tue Jun 23, 2015 9:07 am
by jburel
Hi Olivier

The problem has been fixed, I have opened a pull request.
The issue was due to the fact that in insight, we were expecting an alpha value for the color.
The fixed will be available in the next release in the meantime you set a color e.g. (255,0,0,255) it will be displayed.

Cheers
Jmarie