"Pattern Overlay" for live view in mm2

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

"Pattern Overlay" for live view in mm2

centswu
Hi folks,

Is there a sample script to do "Pattern Overlay" for  live view in mm2

Thanks,
cents

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: "Pattern Overlay" for live view in mm2

centswu
I wrote one script to control image inspector window, I can control the color mode.
But I can not draw overlays to the live window. Does anyone have an advice for this?

I tried to used 3 methods to draw overlays to live window.
(1) OverlayOptions.drawOverlay(...)
(2) OverlayPanel.drawOverlay(..)
(3) currentGraphics_.drawLine(...)

Thanks,
Cents

=== following is my script ===
import org.micromanager.data.Coords;
import org.micromanager.data.Image;
import org.micromanager.data.Datastore;
import org.micromanager.display;
import org.micromanager.display.DisplayWindow;
import org.micromanager.display.OverlayPanel;
import org.micromanager.Studio;
import org.micromanager.patternoverlay;
import org.micromanager.display.internal.DefaultDisplayWindow;
import ij.ImagePlus;
import ij.ImageStack;
import ij.gui.ImageCanvas;

import ij.gui.ImageCanvas;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.HashMap;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;

//addClassPath("C:/Program Files/Micro-Manager-2.0beta/mmplugins/PatternOverlay.jar");
mm.scripter().message("=== Turn on Live Mode  ===");
mm.live().setLiveMode(true);
Thread.sleep(500);
DisplayManager = mm.displays();
PluginManager  = mm.plugins();
DisplayWindow = DisplayManager.getCurrentWindow();
mm.scripter().message("current Window Name : " + DisplayWindow.getName());
DisplaySettings = DisplayWindow.getDisplaySettings();
DisplaySettingsBuilder= DisplaySettings.copy();

mm.scripter().message("=== Set Color Mode to Composite ===");
ColorMode = DisplaySettings.getChannelColorMode();
DisplaySettingsBuilder.channelColorMode(ColorMode.fromInt(1));
DisplaySettings = DisplaySettingsBuilder.build();
DisplayWindow.setDisplaySettings(DisplaySettings);

// Plugin
mm.scripter().message("=== Set OverlayPanel Plugin ===");
PluginManager = mm.plugins();
plugins = PluginManager.getOverlayPlugins();

for (String key : plugins.keySet()) {
      mm.scripter().message("OverlayPlugin : " + key);
      plugin = plugins.get(key);
}
plugin = plugins.get("org.micromanager.patternoverlay.PatternOverlayPlugin");
mm.scripter().message(plugin.getName());
mm.scripter().message(plugin.getVersion());
mm.scripter().message(plugin.getCopyright());
ImageList = DisplayWindow.getDisplayedImages();
Image MMimage;
for(MMimage : ImageList) {
mm.scripter().message( "MMImage" );
}
mm.scripter().message( " image.getIntensityStringAt " + MMimage.getIntensityStringAt(200,200) );

OverlayPanelFactory = plugin.createFactory();
OverlayPanel = OverlayPanelFactory.createOverlayPanel();
canvasSize = DisplayWindow.getCanvas().getSize();

mm.scripter().message( String.valueOf(canvasSize.width) );
mm.scripter().message( String.valueOf(canvasSize.height) );

currentImage_ = new BufferedImage(canvasSize.width,canvasSize.height, BufferedImage.TYPE_INT_RGB);
mm.scripter().message( " image.getIntensityStringAt " + MMimage.getIntensityStringAt(200,200) );

currentGraphics_ = currentImage_.createGraphics();

width = canvasSize.width / 100 /2 ;
height = canvasSize.height / 100 /2;

currentGraphics_.setColor(Color.red);
currentGraphics_.drawLine(0,0,200,200);

//object args;

String units ="px";
pixelSize = MMimage.getMetadata().getPixelSizeUm();
mm.scripter().message( " pixelSize " + pixelSize );
units = "\u00b5m";
zoom = DisplayWindow.getDisplaySettings().getMagnification();

currentGraphics_.setFont(new Font("Arial", Font.PLAIN, 12));
currentGraphics_.drawString("test",150,500);

OverlayOptions = new org.micromanager.patternoverlay.OverlayOptions();
OverlayOptions.drawOverlay(currentGraphics_, DisplayWindow, MMimage, DisplayWindow.getCanvas(), "Crosshair" ,2, "Red",true) ;  

currentGraphics_.setColor(Color.red);

OverlayPanel.drawOverlay(currentGraphics_, DisplayWindow, MMimage, DisplayWindow.getCanvas());
OverlayPanel.redraw();
OverlayPanel.setDisplay(DisplayWindow);
OverlayPanel.setManager(DisplayManager);



DisplayWindow.getCanvas().paint(currentGraphics_);
DisplayWindow.getCanvas().paintToGraphics(currentGraphics_);
DisplayWindow.getCanvas().zoomCanvas(1);

OverlayPanel.redraw();
overlaypanel.setDisplay(DisplayWindow);
OverlayPanel.setManager(DisplayManager); 



2017-08-28 16:07 GMT+08:00 cents wu <[hidden email]>:
Hi folks,

Is there a sample script to do "Pattern Overlay" for  live view in mm2

Thanks,
cents


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general