public void setSelected(int selected) { this.selectedImage = selected; this.isUndistorted = false; if (origMS == null) { BufferedImage image = images.get(selected); // the number of bands can be difficult to ascertain without digging deep into the data // structure // so just declare a new one using convert origMS = ConvertBufferedImage.convertFromMulti(image, null, true, ImageFloat32.class); correctedMS = ConvertBufferedImage.convertFromMulti(image, null, true, ImageFloat32.class); undistorted = new BufferedImage(image.getWidth(), image.getHeight(), image.getType()); } }
private void undoRadialDistortion(BufferedImage image) { ConvertBufferedImage.convertFromMulti(image, origMS, true, ImageFloat32.class); for (int i = 0; i < origMS.getNumBands(); i++) { ImageFloat32 in = origMS.getBand(i); ImageFloat32 out = correctedMS.getBand(i); undoRadial.apply(in, out); } if (correctedMS.getNumBands() == 3) ConvertBufferedImage.convertTo(correctedMS, undistorted, true); else if (correctedMS.getNumBands() == 1) ConvertBufferedImage.convertTo(correctedMS.getBand(0), undistorted); else throw new RuntimeException("What kind of image has " + correctedMS.getNumBands() + "???"); }