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

Method changeValues

ij/src/main/java/ij/macro/Functions.java:1249–1293  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1247 }
1248
1249 void changeValues() {
1250 double darg1 = getFirstArg();
1251 double darg2 = getNextArg();
1252 double darg3 = getLastArg();
1253 ImagePlus imp = getImage();
1254 ImageProcessor ip = getProcessor();
1255 Roi roi = imp.getRoi();
1256 ImageProcessor mask = null;
1257 if (roi==null || !roi.isArea()) {
1258 ip.resetRoi();
1259 roi = null;
1260 } else {
1261 ip.setRoi(roi);
1262 mask = ip.getMask();
1263 if (mask!=null) ip.snapshot();
1264 }
1265 int xmin=0, ymin=0, xmax=imp.getWidth(), ymax=imp.getHeight();
1266 if (roi!=null) {
1267 Rectangle r = roi.getBounds();
1268 xmin=r.x; ymin=r.y; xmax=r.x+r.width; ymax=r.y+r.height;
1269 }
1270 boolean isFloat = getType()==ImagePlus.GRAY32;
1271 if (imp.getBitDepth()==24) {
1272 darg1 = (int)darg1&0xffffff;
1273 darg2 = (int)darg2&0xffffff;
1274 }
1275 double v;
1276 for (int y=ymin; y<ymax; y++) {
1277 for (int x=xmin; x<xmax; x++) {
1278 v = isFloat?ip.getPixelValue(x,y):ip.getPixel(x,y)&0xffffff;
1279 boolean replace = v>=darg1 && v<=darg2;
1280 if (Double.isNaN(darg1) && Double.isNaN(darg2) && Double.isNaN(v))
1281 replace = true;
1282 if (replace) {
1283 if (isFloat)
1284 ip.putPixelValue(x, y, darg3);
1285 else
1286 ip.putPixel(x, y, (int)darg3);
1287 }
1288 }
1289 }
1290 if (mask!=null) ip.reset(mask);
1291 imp.updateAndDraw();
1292 updateNeeded = false;
1293 }
1294
1295 void requires() {
1296 if (IJ.versionLessThan(getStringArg()))

Callers 1

doFunctionMethod · 0.95

Calls 15

getFirstArgMethod · 0.95
getNextArgMethod · 0.95
getLastArgMethod · 0.95
getImageMethod · 0.95
getProcessorMethod · 0.95
getRoiMethod · 0.95
isAreaMethod · 0.95
resetRoiMethod · 0.95
setRoiMethod · 0.95
getMaskMethod · 0.95
snapshotMethod · 0.95
getWidthMethod · 0.95

Tested by

no test coverage detected