Hi BK,
Suppose you have a cell region ROI mask(s), which is a binary image with the same size as the original image. Only the cell region is bright (1) and the background is black (0).
Then could you tell me
1. how to attach this ROI mask to the original image by using the Bio-Format API? A sample code will be very appreciated.
If you have a MetadataStore object named 'store' and your mask is a byte array named 'mask':
- Code: Select all
// set the mask to be the 0th Shape on the 0th ROI
store.setROIID("ROI:0", 0);
store.setMaskID("Shape:0:0", 0, 0);
store.setMaskBinData(mask, 0, 0);
store.setMaskX(0d, 0, 0); // the X coordinate of the upper-left corner of the mask, relative to the image
store.setMaskY(0d, 0, 0); // the Y coordinate of the upper-left corner of the mask, relative to the image
store.setMaskWidth(width, 0, 0); // the width in pixels of mask
store.setMaskHeight(height, 0, 0); // the height in pixels of the mask
// link the mask's parent ROI to the 0th Image
store.setImageROIRef("ROI:0", 0, 0);
2. after the attachment, how to recognize that the ROI is a "cell region" mask, rather than a rectangular, circle, or line. I'm asking this becasue there could be also other ROIs attached to the image, and other masks as well. But we need to retrieve the "cell region" masks for our own purpose. Can we put a name to the ROI mask (such as "cell_001") and recognize by its name? If so, could you tell me the API function that put/retrieve the name to/from the ROI? (A sample code will be more straight-forward).
You could certainly use the Name or Description attributes of Mask to identify in your own code whether or not the Mask corresponds to a cell region. To populate those attributes (assuming that the above code is already in place):
- Code: Select all
store.setMaskName("Cell region", 0, 0);
store.setMaskDescription("This really is a cell region, and not anything else.", 0, 0);
And to retrieve the name and description, if you have a MetadataRetrieve object named 'retrieve':
- Code: Select all
String name = retrieve.getMaskName(0, 0);
String description = retrieve.getMaskDescription(0, 0);
Regards,
-Melissa