From 806910b110356814ac8160f57acc8f423590e9b5 Mon Sep 17 00:00:00 2001 From: Nico Stuurman Date: Fri, 10 Jul 2020 12:26:29 -0700 Subject: [PATCH] ChannelCorrector: Switch to nearest neighbor interpolation, as Bicubic leads to weird grey scale distributions. May need to switch to using BoofCV. --- .../micromanager/channelcorrector/ChannelCorrectorFrame.java | 3 ++- .../channelcorrector/utils/ImageAffineTransform.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/ChannelCorrector/src/main/java/org/micromanager/channelcorrector/ChannelCorrectorFrame.java b/plugins/ChannelCorrector/src/main/java/org/micromanager/channelcorrector/ChannelCorrectorFrame.java index ad530e2443..2909f347b3 100644 --- a/plugins/ChannelCorrector/src/main/java/org/micromanager/channelcorrector/ChannelCorrectorFrame.java +++ b/plugins/ChannelCorrector/src/main/java/org/micromanager/channelcorrector/ChannelCorrectorFrame.java @@ -164,8 +164,9 @@ public void apply() throws IOException, ImageAffineTransformException { for (ChannelCorrectorPanel ccp : channelCorrectorPanels_) { affineTransforms.add(ccp.getAffineTransform()); } + // Note that types other than Nearest Neighbor lead to strange pixel values ImageAffineTransform iat = new ImageAffineTransform(studio_, dataViewer_, - affineTransforms, AffineTransformOp.TYPE_BICUBIC); + affineTransforms, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); iat.apply(settings_.getBoolean(USE_ALL_POS_KEY, false)); studio_.alerts().postAlert("ChannelCorrector", this.getClass(), "Finished correcting " + dataViewerName); diff --git a/plugins/ChannelCorrector/src/main/java/org/micromanager/channelcorrector/utils/ImageAffineTransform.java b/plugins/ChannelCorrector/src/main/java/org/micromanager/channelcorrector/utils/ImageAffineTransform.java index 59284c09fe..5937a8e0da 100644 --- a/plugins/ChannelCorrector/src/main/java/org/micromanager/channelcorrector/utils/ImageAffineTransform.java +++ b/plugins/ChannelCorrector/src/main/java/org/micromanager/channelcorrector/utils/ImageAffineTransform.java @@ -190,11 +190,14 @@ public Image transformImage(Image inImg, AffineTransformOp aOp, int width, int h BufferedImage bi16 = testProc.get16BitBufferedImage(); BufferedImage aOpResult = new BufferedImage(bi16.getWidth(), bi16.getHeight(), BufferedImage.TYPE_USHORT_GRAY); + aOp.filter(bi16, aOpResult); if (interpolationType_ == AffineTransformOp.TYPE_NEAREST_NEIGHBOR) { aOp.filter(bi16, aOpResult); } else { // work around bug in AffineTransformationOp, see: // http://stackoverflow.com/questions/2428109/java-error-on-bilinear-interpolation-of-16-bit-data + // Note: although the image looks alright, histogram values are strangely distorted + // presumably, since calculations are done with bytes rather than shorts Graphics2D g = aOpResult.createGraphics(); g.transform(aOp.getTransform()); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, renderingHint_);