void doIterations(ImageProcessor ip, String mode) { if (escapePressed) return; if (!previewing && iterations > 1) IJ.showStatus(arg + "... press ESC to cancel"); for (int i = 0; i < iterations; i++) { if (Thread.currentThread().isInterrupted()) return; if (IJ.escapePressed()) { escapePressed = true; ip.reset(); return; } if (mode.equals("erode")) ((ByteProcessor) ip).erode(count, background); else ((ByteProcessor) ip).dilate(count, background); } }