MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getRoi

Method getRoi

ij/src/main/java/ij/io/RoiDecoder.java:166–416  ·  view source on GitHub ↗

Returns the ROI.

()

Source from the content-addressed store, hash-verified

164
165 /** Returns the ROI. */
166 public Roi getRoi() throws IOException {
167 if (path!=null) {
168 File f = new File(path);
169 size = (int)f.length();
170 if (!path.endsWith(".roi") && size>5242880)
171 throw new IOException("This is not an ROI or file size>5MB)");
172 name = f.getName();
173 is = new FileInputStream(path);
174 }
175 data = new byte[size];
176
177 int total = 0;
178 while (total<size)
179 total += is.read(data, total, size-total);
180 is.close();
181 if (getByte(0)!=73 || getByte(1)!=111) //"Iout"
182 throw new IOException("This is not an ImageJ ROI");
183 int version = getShort(VERSION_OFFSET);
184 int type = getByte(TYPE);
185 int subtype = getShort(SUBTYPE);
186 int top= getShort(TOP);
187 int left = getShort(LEFT);
188 int bottom = getShort(BOTTOM);
189 int right = getShort(RIGHT);
190 int width = right-left;
191 int height = bottom-top;
192 int n = getUnsignedShort(N_COORDINATES);
193 if (n==0)
194 n = getInt(SIZE);
195 int options = getShort(OPTIONS);
196 int position = getInt(POSITION);
197 int hdr2Offset = getInt(HEADER2_OFFSET);
198 int channel=0, slice=0, frame=0;
199 int overlayLabelColor=0;
200 int overlayFontSize=0;
201 int group=0;
202 int imageOpacity=0;
203 int imageSize=0;
204 boolean subPixelResolution = (options&SUB_PIXEL_RESOLUTION)!=0 && version>=222;
205 boolean drawOffset = subPixelResolution && (options&DRAW_OFFSET)!=0;
206 boolean scaleStrokeWidth = true;
207 if (version>=228)
208 scaleStrokeWidth = (options&SCALE_STROKE_WIDTH)!=0;
209
210 boolean subPixelRect = version>=223 && subPixelResolution && (type==rect||type==oval);
211 double xd=0.0, yd=0.0, widthd=0.0, heightd=0.0;
212 if (subPixelRect) {
213 xd = getFloat(XD);
214 yd = getFloat(YD);
215 widthd = getFloat(WIDTHD);
216 heightd = getFloat(HEIGHTD);
217 }
218
219 if (hdr2Offset>0 && hdr2Offset+IMAGE_SIZE+4<=size) {
220 channel = getInt(hdr2Offset+C_POSITION);
221 slice = getInt(hdr2Offset+Z_POSITION);
222 frame = getInt(hdr2Offset+T_POSITION);
223 overlayLabelColor = getInt(hdr2Offset+OVERLAY_LABEL_COLOR);

Callers 15

openRoiMethod · 0.95
openZipMethod · 0.95
openMethod · 0.95
openFromByteArrayMethod · 0.95
openRoiMethod · 0.95
makeOvalMethod · 0.45
makeRectangleMethod · 0.45
displayBatchModeImageMethod · 0.45
getStatisticsMethod · 0.45
setSelectionNameMethod · 0.45
selectionNameMethod · 0.45
isMethod · 0.45

Calls 15

getByteMethod · 0.95
getShortMethod · 0.95
getUnsignedShortMethod · 0.95
getIntMethod · 0.95
getFloatMethod · 0.95
getShapeRoiMethod · 0.95
setPositionMethod · 0.95
decodeOverlayOptionsMethod · 0.95
getRoiPropsMethod · 0.95
setPropertiesMethod · 0.95
setGroupMethod · 0.95

Tested by

no test coverage detected