Re: [micro-manager-general] Spam (12.588):Re: Steps to get a functional plugin, lesson n+1
Status: Beta
Brought to you by:
nicost
|
From: Nico S. <nic...@uc...> - 2020-04-09 21:24:01
|
Hi Carlos,
> Allmost there.
> I've have steps 1, 2 & 3 working, but for a minor thing: intensity
> values are not right.
That sounds like real progress!
> I was hoping to use ImageJ stuff to do the calculations (so it is easy
> to update, upgrade, whatever) but as noted in another message, the
> liaison is complicated...
>
> My point drawing code now looks like:
>
> @Subscribe
> public void onNewImage(DataProviderHasNewImageEvent event) {
> imagesReceived_++;
> if (skip_ != 0 && imagesReceived_ % (skip_+1) != 1)
> return; // 1Hz max
> double v;
> title.setText("You should be seeing data on the plot.");
> image_ = studio_.displays().getAllImageWindows().get(0).getImagePlus();
> for (int i = 0; i < ROIs_-1; i++) {
> image_.getProcessor().setRoi(roi_[i]);
> v = image_.getProcessor().getStats().mean;
> data[i].add((double)imagesReceived_, v, false);
> }
> image_.getProcessor().setRoi(roi_[ROIs_ - 1]);
> v = image_.getProcessor().getStats().mean;
> data[ROIs_ - 1].add((double)imagesReceived_, v, true);
> }
> }
>
> data[] are the JFreeChart data series corresponding to preset ROIs.
> skip_ is use to control refresh rate, not to create 100 pps (points per
> second) :)
Haven't looked at this directly, but it seems safer to use the event
directly to get the image:
image = event.getImage();
You can then
studio_.ij().createProcessor(image)
to get the ImageJ ImageProcessor, and get the stats from there.
At the surface, looks similar to what you have, but avoids calling the
deprecated DisplayWindow.getImagePlus(), which has the scary looking
javadoc:
@deprecated Directly accessing the {@code ImagePlus} of an MMStudio *
display window will generally result in very fragile code. Consider *
accessing image data through {@link #getDataProvider}. For drawing *
overlay graphics, see {@link #addOverlay}. */ @Deprecated public ImagePlusgetImagePlus();
Best,
Nico
|