I try to use ROI schema from Matlab to place our image segmentation results in Omero, and have couple of, hopefully, very simple questions.
I succeeded to transfer bounding rectangles around each object - they are seen in Omero Web browser.
But the idea is, certainly, to transfer shapes (or "masks" - not sure which term is proper. blobs, anyway).
The code below uses the segmented image "segmmask" as source of "masks" and attaches ROI with corresponding "masks" to the Omero image:
- Code: Select all
stats = regionprops(segmmask,'PixelList');
for k=1:numel(stats)
X = stats(k).PixelList(:,1);
Y = stats(k).PixelList(:,2);
%
x0 = min(X);
y0 = min(Y);
W = max(X) - x0 + 1;
H = max(Y) - y0 + 1;
%
m = zeros(W,H);
for j = 1 : numel(X),
x = X(j) - x0 + 1;
y = Y(j) - y0 + 1;
m(x,y) = 1;
end
%
mask = createMask(x0,y0,m);
setShapeCoordinates(mask, 0, 0, 0);
%
roi = omero.model.RoiI;
roi.addShape(mask);
roi.setImage(omero.model.ImageI(image.getId.getValue, false));
roi = iUpdate.saveAndReturnObject(roi);
end
first, I'm not sure it is correct.
second, - imported ROIs and shapes are not visible in Omero-web.
third - I didn't find way how to retrieve these pixels back (which is the matter of significant interest..).
Using the example I found how to access the "mask" object if it is there:
- Code: Select all
service = obj.session.getRoiService();
roiResult = service.findByImage(image.getId.getValue, []);
rois = roiResult.rois;
n = rois.size;
for thisROI = 1:n
roi = rois.get(thisROI-1);
numShapes = roi.sizeOfShapes; % an ROI can have multiple shapes.
for ns = 1:numShapes
shape = roi.getShape(ns-1); % the shape
if (isa(shape, 'omero.model.Mask'))
shape
% mmmmmmmmmmmm... WHAT TO DO NEXT?
end
end
end
So basically I would like to get some quick refs/usage examples for the functions managing access, visibility, and attributes of these blobs' pixels.
Best regards,
Y.