use of ij.ImagePlus in project GDSC-SMLM by aherbert.
the class SpotAnalysis method imageUpdated.
/*
* (non-Javadoc)
*
* @see ij.ImageListener#imageUpdated(ij.ImagePlus)
*/
public void imageUpdated(ImagePlus imp) {
ImagePlus from = null, to = null;
if (imp == rawImp) {
from = rawImp;
to = blurImp;
} else if (imp == blurImp) {
from = blurImp;
to = rawImp;
}
if (from != null) {
int slice = from.getCurrentSlice();
updateCurrentSlice(slice);
if (to != null) {
if (to.getCurrentSlice() != slice) {
//System.out.println("updating image");
to.setSlice(slice);
//to.resetDisplayRange();
}
}
}
}
use of ij.ImagePlus in project GDSC-SMLM by aherbert.
the class PulseActivationAnalysis method displayComposite.
private void displayComposite(ImageProcessor[] images, String name) {
// We do not yet know the size
ImageStack stack = null;
for (int i = 0; i < images.length; i++) {
ImageProcessor ip = images[i];
if (stack == null)
stack = new ImageStack(ip.getWidth(), ip.getHeight());
ip.setColorModel(null);
stack.addSlice("C" + (i + 1), ip);
}
// Create a composite
ImagePlus imp = new ImagePlus(name, stack);
imp.setDimensions(images.length, 1, 1);
CompositeImage ci = new CompositeImage(imp, IJ.COMPOSITE);
// Make it easier to see
//ij.plugin.ContrastEnhancerce = new ij.plugin.ContrastEnhancer();
//double saturated = 0.35;
//ce.stretchHistogram(ci, saturated);
autoAdjust(ci, ci.getProcessor());
imp = WindowManager.getImage(name);
if (imp != null && imp.isComposite()) {
ci.setMode(imp.getCompositeMode());
imp.setImage(ci);
imp.getWindow().toFront();
} else {
ci.show();
imp = ci;
}
if (WindowManager.getWindow("Channels") == null) {
IJ.run("Channels Tool...");
Window w = WindowManager.getWindow("Channels");
if (w == null)
return;
Window w2 = imp.getWindow();
if (w2 == null)
return;
java.awt.Point p = w2.getLocation();
p.x += w2.getWidth();
w.setLocation(p);
}
}
use of ij.ImagePlus in project GDSC-SMLM by aherbert.
the class ConfigurationTemplateTest method canLoadTemplateImageFromFile.
@Test
public void canLoadTemplateImageFromFile() throws IOException {
ConfigurationTemplate.clearTemplates();
Assert.assertEquals(0, ConfigurationTemplate.getTemplateNamesWithImage().length);
// Create a dummy image
int size = 20;
float[] pixels = new float[size * size];
RandomGenerator r = new Well19937c();
for (int i = pixels.length; i-- > 0; ) pixels[i] = r.nextFloat();
ImagePlus imp = new ImagePlus("test", new FloatProcessor(size, size, pixels));
File tmpFile = File.createTempFile("tmp", ".tif");
tmpFile.deleteOnExit();
IJ.save(imp, tmpFile.getPath());
String name = "canLoadTemplateImageFromFile";
File file = new File(Utils.replaceExtension(tmpFile.getPath(), ".xml"));
ConfigurationTemplate.saveTemplate(name, new GlobalSettings(), file);
Assert.assertEquals(1, ConfigurationTemplate.getTemplateNamesWithImage().length);
ImagePlus imp2 = ConfigurationTemplate.getTemplateImage(name);
Assert.assertNotNull(imp2);
float[] data = (float[]) imp2.getProcessor().toFloat(0, null).getPixels();
Assert.assertArrayEquals(pixels, data, 0);
}
use of ij.ImagePlus in project GDSC-SMLM by aherbert.
the class BatchPeakFit method runBatch.
/**
* Reads the batch configuration file. For each parameter variation, create a fitting configuration. Then run the
* fit engine on each input image using each configuration.
*
* @param configurationFilename
*/
private void runBatch(String configurationFilename) {
BatchSettings settings = loadSettings(configurationFilename);
if (settings == null || settings.parameters.isEmpty()) {
IJ.log("No settings for the fitting engine");
return;
}
if (!new File(settings.resultsDirectory).exists()) {
if (!new File(settings.resultsDirectory).mkdirs()) {
IJ.log("Unable to create the results directory: " + settings.resultsDirectory);
return;
}
}
Document doc = getDefaultSettingsXmlDocument();
if (doc == null)
return;
// Create XML for each variation
ArrayList<String> xmlSettings = new ArrayList<String>();
setParameters(settings.parameters, 0, doc, xmlSettings);
// Run all the variants on the input images
for (String imageFilename : settings.images) {
ImagePlus imp = IJ.openImage(imageFilename);
if (imp == null) {
IJ.log("Unable to load image: " + imageFilename);
continue;
}
processImage(settings, imp, xmlSettings);
}
}
use of ij.ImagePlus in project GDSC-SMLM by aherbert.
the class FIRE method showInputDialog.
private boolean showInputDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addMessage("Compute the resolution using Fourier Ring Correlation");
gd.addHelp(About.HELP_URL);
// Build a list of all images with a region ROI
List<String> titles = new LinkedList<String>();
if (WindowManager.getWindowCount() > 0) {
for (int imageID : WindowManager.getIDList()) {
ImagePlus imp = WindowManager.getImage(imageID);
if (imp != null && imp.getRoi() != null && imp.getRoi().isArea())
titles.add(imp.getTitle());
}
}
ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
ResultsManager.addInput(gd, "Input2", inputOption2, InputSource.NONE, InputSource.MEMORY);
if (!titles.isEmpty())
gd.addCheckbox((titles.size() == 1) ? "Use_ROI" : "Choose_ROI", chooseRoi);
gd.showDialog();
if (gd.wasCanceled())
return false;
inputOption = ResultsManager.getInputSource(gd);
inputOption2 = ResultsManager.getInputSource(gd);
if (!titles.isEmpty())
chooseRoi = gd.getNextBoolean();
if (!titles.isEmpty() && chooseRoi) {
if (titles.size() == 1) {
roiImage = titles.get(0);
Recorder.recordOption("Image", roiImage);
} else {
String[] items = titles.toArray(new String[titles.size()]);
gd = new ExtendedGenericDialog(TITLE);
gd.addMessage("Select the source image for the ROI");
gd.addChoice("Image", items, roiImage);
gd.showDialog();
if (gd.wasCanceled())
return false;
roiImage = gd.getNextChoice();
}
ImagePlus imp = WindowManager.getImage(roiImage);
roiBounds = imp.getRoi().getBounds();
roiImageWidth = imp.getWidth();
roiImageHeight = imp.getHeight();
} else {
roiBounds = null;
}
return true;
}
Aggregations