Skip to content

Commit

Permalink
ChannelCorrector: Switch to nearest neighbor interpolation,
Browse files Browse the repository at this point in the history
as Bicubic leads to weird grey scale distributions.
May need to switch to using BoofCV.
  • Loading branch information
nicost committed Jul 10, 2020
1 parent eed5bf2 commit 806910b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down

0 comments on commit 806910b

Please sign in to comment.