Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
File roi.py,
1.3 KB
(added by wmoore, 9 years ago) |
Script to create shapes
|
Line | |
---|
1 | |
---|
2 | from omero.gateway import BlitzGateway |
---|
3 | import omero |
---|
4 | from omero.rtypes import rdouble, rstring, rint |
---|
5 | from omero.model.enums import UnitsLength |
---|
6 | |
---|
7 | conn = BlitzGateway('user', 'password') |
---|
8 | conn.connect() |
---|
9 | |
---|
10 | image = conn.getObject("Image", 8552) |
---|
11 | |
---|
12 | |
---|
13 | updateService = conn.getUpdateService() |
---|
14 | |
---|
15 | for core_id in [1, 2]: |
---|
16 | |
---|
17 | # add one new rectangle ROI |
---|
18 | x = 100 * core_id |
---|
19 | y = 100 * core_id |
---|
20 | width = 50 |
---|
21 | height = 50 |
---|
22 | theZ = 0 |
---|
23 | theT = 0 |
---|
24 | |
---|
25 | # create an ROI, link it to Image |
---|
26 | roi = omero.model.RoiI() |
---|
27 | |
---|
28 | # use the omero.model.ImageI that underlies the 'image' wrapper |
---|
29 | roi.setImage(image._obj) |
---|
30 | |
---|
31 | # create a rectangle shape and add to ROI |
---|
32 | rect = omero.model.RectI() |
---|
33 | rect.x = rdouble(x) |
---|
34 | rect.y = rdouble(y) |
---|
35 | rect.width = rdouble(width) |
---|
36 | rect.height = rdouble(height) |
---|
37 | rect.theZ = rint(theZ) |
---|
38 | rect.theT = rint(theT) |
---|
39 | rect.textValue = rstring(str(core_id)) |
---|
40 | |
---|
41 | ## problem occurs in java client 5.1.2 Ice35 b45, |
---|
42 | ## when the following lines are uncommented, |
---|
43 | ## web viewer is ok |
---|
44 | rect.strokeColor = rint(0xff0000) |
---|
45 | strokeWidth = omero.model.LengthI(5, UnitsLength.PIXEL) |
---|
46 | rect.strokeWidth = strokeWidth |
---|
47 | fontSize = omero.model.LengthI(50, UnitsLength.PIXEL) |
---|
48 | rect.fontSize = fontSize |
---|
49 | |
---|
50 | roi.addShape(rect) |
---|
51 | |
---|
52 | # Save the ROI (saves any linked shapes too) |
---|
53 | r = updateService.saveAndReturnObject(roi) |
---|
Download in other formats:
1.3.13-PRO © 2008-2011
Agilo Software all
rights reserved
(this page was served in: 0.14215 sec.)