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

Method scale

ij/src/main/java/ij/plugin/Scaler.java:170–214  ·  view source on GitHub ↗
(ImagePlus imp)

Source from the content-addressed store, hash-verified

168 }
169
170 private void scale(ImagePlus imp) {
171 ImageProcessor ip = imp.getProcessor();
172 if (newWindow) {
173 Rectangle r = ip.getRoi();
174 ImagePlus imp2 = imp.createImagePlus();
175 imp2.setProcessor(title, ip.resize(newWidth, newHeight, averageWhenDownsizing));
176 Calibration cal = imp2.getCalibration();
177 if (cal.scaled()) {
178 cal.pixelWidth *= 1.0/xscale;
179 cal.pixelHeight *= 1.0/yscale;
180 }
181 cal.xOrigin *= xscale;
182 cal.yOrigin *= yscale;
183 Overlay overlay = imp.getOverlay();
184 if (overlay!=null && !imp.getHideOverlay()) {
185 overlay = overlay.duplicate();
186 int slice = imp.getCurrentSlice();
187 overlay.crop(slice,slice);
188 Rectangle roi = imp.getProcessor().getRoi();
189 if (roi!=null)
190 overlay = overlay.crop(ip.getRoi());
191 overlay = overlay.scale(xscale, yscale);
192 imp2.setOverlay(overlay);
193 }
194 imp2.show();
195 imp.trimProcessor();
196 imp2.trimProcessor();
197 imp2.changes = true;
198 } else {
199 if (processStack && imp.getStackSize()>1) {
200 Undo.reset();
201 StackProcessor sp = new StackProcessor(imp.getStack(), ip);
202 sp.scale(xscale, yscale, bgValue);
203 } else {
204 ip.snapshot();
205 Undo.setup(Undo.FILTER, imp);
206 ip.setSnapshotCopyMode(true);
207 ip.scale(xscale, yscale);
208 ip.setSnapshotCopyMode(false);
209 }
210 imp.deleteRoi();
211 imp.updateAndDraw();
212 imp.changes = true;
213 }
214 }
215
216 public static void record(ImagePlus imp, int w2, int h2, int d2, int method) {
217 if (!Recorder.scriptMode())

Callers 1

runMethod · 0.95

Calls 15

getRoiMethod · 0.95
setProcessorMethod · 0.95
resizeMethod · 0.95
getCalibrationMethod · 0.95
scaledMethod · 0.95
duplicateMethod · 0.95
cropMethod · 0.95
scaleMethod · 0.95
setOverlayMethod · 0.95
showMethod · 0.95
trimProcessorMethod · 0.95
resetMethod · 0.95

Tested by

no test coverage detected