Commit b6a7bf3f authored by lafabregue's avatar lafabregue

finished pyramid iamge implementation

parent 0f66b211
...@@ -123,7 +123,7 @@ public class MainFrame extends JFrame { ...@@ -123,7 +123,7 @@ public class MainFrame extends JFrame {
private JPanel infosPanel; private JPanel infosPanel;
/** boolean pour lier le birdview avec l'image active */ /** boolean pour lier le birdview avec l'image active */
private boolean lierBirdView = false; private boolean linkToAllImages = false;
/** the project root for datas */ /** the project root for datas */
private DefaultMutableTreeNode mDataProjectNode; private DefaultMutableTreeNode mDataProjectNode;
...@@ -1310,8 +1310,8 @@ public class MainFrame extends JFrame { ...@@ -1310,8 +1310,8 @@ public class MainFrame extends JFrame {
menuBrightM.setEnabled(this.actionBrightM); menuBrightM.setEnabled(this.actionBrightM);
menuContrastP.setEnabled(this.actionContratsP); menuContrastP.setEnabled(this.actionContratsP);
menuContrastM.setEnabled(this.actionContrastM); menuContrastM.setEnabled(this.actionContrastM);
menuConnectActiv.setEnabled(!this.isLierBirdView()); menuConnectActiv.setEnabled(!this.isLinkToAllBirdView());
menuConnectAll.setEnabled(this.isLierBirdView()); menuConnectAll.setEnabled(this.isLinkToAllBirdView());
menuResetAll.setEnabled(this.actionResetAll); menuResetAll.setEnabled(this.actionResetAll);
menuChooseRgb.setEnabled(this.actionChooseRgb); menuChooseRgb.setEnabled(this.actionChooseRgb);
menuRefresh.setEnabled(this.actionRefresh); menuRefresh.setEnabled(this.actionRefresh);
...@@ -1480,7 +1480,7 @@ public class MainFrame extends JFrame { ...@@ -1480,7 +1480,7 @@ public class MainFrame extends JFrame {
// =============== Creation of the Desktop ================ // =============== Creation of the Desktop ================
JPanel panel_desktop = new JPanel(new BorderLayout()); JPanel panel_desktop = new JPanel(new BorderLayout());
panel_desktop.setOpaque(false); panel_desktop.setOpaque(false);
panel_desktop.setBorder(Borders.DIALOG); panel_desktop.setBorder(Borders.DIALOG_BORDER);
panel_desktop.add(this.desktop); panel_desktop.add(this.desktop);
sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$ sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$
...@@ -1494,7 +1494,7 @@ public class MainFrame extends JFrame { ...@@ -1494,7 +1494,7 @@ public class MainFrame extends JFrame {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false); panel.setOpaque(false);
panel.setBorder(Borders.DIALOG); panel.setBorder(Borders.DIALOG_BORDER);
panel.add(pane); panel.add(pane);
// =============== Creation of the Progress Panel => South // =============== Creation of the Progress Panel => South
...@@ -1530,36 +1530,6 @@ public class MainFrame extends JFrame { ...@@ -1530,36 +1530,6 @@ public class MainFrame extends JFrame {
this.birdPanel.requestFocus(); this.birdPanel.requestFocus();
} }
//TODO to remove
// method for resizing an image while keeping aspect ratio
private static BufferedImage resizeImage(BufferedImage originalImage, int type, int frameWidth, int frameHeight) {
double height = originalImage.getHeight();
double width = originalImage.getWidth();
int newWidth, newHeight;
// if image size smaller than window size, do not resize
if (height < frameHeight && width < frameWidth) {
newWidth = (int) width;
newHeight = (int) height;
}
// else resize
else {
double scaleX = (frameWidth / width);
double scaleY = (frameHeight / height);
double scale = Math.min(scaleX, scaleY);
newWidth = (int) (width * scale);
newHeight = (int) (height * scale);
}
BufferedImage resizedImage = new BufferedImage(newWidth, newHeight, type);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(originalImage, 0, 0, newWidth, newHeight, null);
g.dispose();
return resizedImage;
}
// 20120309_MBH-Test-Fin // 20120309_MBH-Test-Fin
/** /**
...@@ -1647,7 +1617,7 @@ public class MainFrame extends JFrame { ...@@ -1647,7 +1617,7 @@ public class MainFrame extends JFrame {
// =============== Creation of the Desktop ================ // =============== Creation of the Desktop ================
JPanel panel_desktop = new JPanel(new BorderLayout()); JPanel panel_desktop = new JPanel(new BorderLayout());
panel_desktop.setOpaque(false); panel_desktop.setOpaque(false);
panel_desktop.setBorder(Borders.DIALOG); panel_desktop.setBorder(Borders.DIALOG_BORDER);
panel_desktop.add(this.desktop); panel_desktop.add(this.desktop);
sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$ sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$
...@@ -1661,7 +1631,7 @@ public class MainFrame extends JFrame { ...@@ -1661,7 +1631,7 @@ public class MainFrame extends JFrame {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false); panel.setOpaque(false);
panel.setBorder(Borders.DIALOG); panel.setBorder(Borders.DIALOG_BORDER);
panel.add(pane); panel.add(pane);
// =============== Creation of the Progress Panel => South // =============== Creation of the Progress Panel => South
...@@ -2494,8 +2464,8 @@ public class MainFrame extends JFrame { ...@@ -2494,8 +2464,8 @@ public class MainFrame extends JFrame {
return mDataTreeModel; return mDataTreeModel;
} }
public boolean isLierBirdView() { public boolean isLinkToAllBirdView() {
return lierBirdView; return linkToAllImages;
} }
/** /**
...@@ -3461,7 +3431,7 @@ public class MainFrame extends JFrame { ...@@ -3461,7 +3431,7 @@ public class MainFrame extends JFrame {
} }
public void setLierBirdView(boolean lierBirdView) { public void setLierBirdView(boolean lierBirdView) {
this.lierBirdView = lierBirdView; this.linkToAllImages = lierBirdView;
setEnabledMenu(); setEnabledMenu();
} }
// //
......
...@@ -288,29 +288,7 @@ public class BirdViewPanel extends JPanel implements MouseListener, ...@@ -288,29 +288,7 @@ public class BirdViewPanel extends JPanel implements MouseListener,
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
// Test if an image is loaded
if (!session.isDisplayEnable() || this.mImage == null) {
return;
}
// Test if the mouse is over the image
if (e.getPoint().x >= this.mBirdImage.getWidth()
|| e.getPoint().y >= this.mBirdImage.getHeight()) {
return;
}
// Zoom factor of the image
double xfact = (double) this.mImage.getWidth()
/ (double) this.mBirdImage.getWidth();
double yfact = (double) this.mImage.getHeight()
/ (double) this.mBirdImage.getHeight();
double x = e.getX() * xfact;
double y = e.getY() * yfact;
this.mInfoPanel.setPixel((int) (x), (int) (y));
repaint();
} }
/** /**
...@@ -631,7 +609,7 @@ public class BirdViewPanel extends JPanel implements MouseListener, ...@@ -631,7 +609,7 @@ public class BirdViewPanel extends JPanel implements MouseListener,
this.repaint(); this.repaint();
this.action = BirdViewPanel.ACT_NONE; this.action = BirdViewPanel.ACT_NONE;
if (!MainFrame.getInstance().isLierBirdView()) { if (!MainFrame.getInstance().isLinkToAllBirdView()) {
ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop() ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllImageDesktopFrames(); .getAllImageDesktopFrames();
int nbSessions = desktopFrames.length; int nbSessions = desktopFrames.length;
...@@ -653,28 +631,13 @@ public class BirdViewPanel extends JPanel implements MouseListener, ...@@ -653,28 +631,13 @@ public class BirdViewPanel extends JPanel implements MouseListener,
.getBirdViewPanel().rysave); .getBirdViewPanel().rysave);
} }
} else { } else {
if (MainFrame.getInstance().getDesktop().getActiveFrame() instanceof ImageDesktopFrame) { if (session != null) {
syncImage(((ImageDesktopFrame) MainFrame.getInstance().getDesktop().getActiveFrame()) syncImage(session);
.getImageSession()); session.getImagePanel().reloadPoint(
((ImageDesktopFrame) MainFrame session.getBirdViewPanel().xxsave,
.getInstance() session.getBirdViewPanel().yysave,
.getDesktop() session.getBirdViewPanel().rxsave,
.getActiveFrame()) session.getBirdViewPanel().rysave);
.getImageSession()
.getImagePanel()
.reloadPoint(
((ImageDesktopFrame) MainFrame.getInstance().getDesktop()
.getActiveFrame()).getImageSession()
.getBirdViewPanel().xxsave,
((ImageDesktopFrame) MainFrame.getInstance().getDesktop()
.getActiveFrame()).getImageSession()
.getBirdViewPanel().yysave,
((ImageDesktopFrame) MainFrame.getInstance().getDesktop()
.getActiveFrame()).getImageSession()
.getBirdViewPanel().rxsave,
((ImageDesktopFrame) MainFrame.getInstance().getDesktop()
.getActiveFrame()).getImageSession()
.getBirdViewPanel().rysave);
} }
} }
......
...@@ -406,11 +406,13 @@ public class ImageInformationPanel extends JPanel { ...@@ -406,11 +406,13 @@ public class ImageInformationPanel extends JPanel {
* </p> * </p>
* *
* @param x * @param x
* the x position of the pixel * the x position of the pixel
* @param y * @param y
* the y position of the pixel * the y position of the pixel
* @param value
* the pixel value
*/ */
public void setPixel(int x, int y) { public void setPixel(int x, int y, double value[]) {
this.mPixel.setText("Pixel: " + (x + 1) + " - " + (y + 1)); this.mPixel.setText("Pixel: " + (x + 1) + " - " + (y + 1));
try { try {
double posGeo[] = this.mImage.getLatLon(x, y); double posGeo[] = this.mImage.getLatLon(x, y);
...@@ -425,19 +427,12 @@ public class ImageInformationPanel extends JPanel { ...@@ -425,19 +427,12 @@ public class ImageInformationPanel extends JPanel {
this.mPixelGeo.setText("Lat: " + myFormatter.format(xgeo) this.mPixelGeo.setText("Lat: " + myFormatter.format(xgeo)
+ " Lon: " + myFormatter.format(ygeo)); + " Lon: " + myFormatter.format(ygeo));
} catch (Exception ex) { } catch (Exception ex) {
if(MainFrame.DEBUG_MODE) // if(MainFrame.DEBUG_MODE)
ex.printStackTrace(); // ex.printStackTrace();
this.mPixelGeo.setText("no georeferencing"); this.mPixelGeo.setText("no georeferencing");
} }
double data[][][] = this.mImage.load(x, y, 1, 1); setPixelVal(this.mImage.getWavelength(), value);
double realdata[] = new double[data.length];
for (int i = 0; i < data.length; i++)
realdata[i] = data[i][0][0];
setPixelVal(this.mImage.getWavelength(), realdata);
} }
/** /**
......
This diff is collapsed.
...@@ -19,11 +19,8 @@ import jcl.Classification; ...@@ -19,11 +19,8 @@ import jcl.Classification;
import jcl.clustering.Cluster; import jcl.clustering.Cluster;
import jcl.clustering.ClusteringResult; import jcl.clustering.ClusteringResult;
import jcl.data.Data; import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData; import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence; import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.attribute.AttributeNumerical;
import jcl.data.mask.Mask;
import jcl.evaluation.clustering.ResultsComparison; import jcl.evaluation.clustering.ResultsComparison;
import jcl.learning.*; import jcl.learning.*;
import jcl.learning.methods.monostrategy.SingleClassification; import jcl.learning.methods.monostrategy.SingleClassification;
...@@ -643,7 +640,7 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen ...@@ -643,7 +640,7 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
} }
MainFrame.getInstance().getCurrentDataSession().addResultPanel(this); MainFrame.getInstance().getCurrentDataSession().addResultPanel(this);
this.result = classification.getClusteringResult(); this.result = classification.getClusteringResult();
//TODO remove comments to allow display again //TODO comment line bellow to disable display
this.colored = new BufferedImage(imgData.getResultWidth(), imgData.getResultHeight(), BufferedImage.TYPE_INT_RGB); this.colored = new BufferedImage(imgData.getResultWidth(), imgData.getResultHeight(), BufferedImage.TYPE_INT_RGB);
if (imgData.getAssociatedImageSessions() != null && imgData.getAssociatedImageSessions().size() > 0) { if (imgData.getAssociatedImageSessions() != null && imgData.getAssociatedImageSessions().size() > 0) {
this.setData(imgData.getAssociatedImageSessions().get(0).getImagePanel().getImage()); this.setData(imgData.getAssociatedImageSessions().get(0).getImagePanel().getImage());
......
...@@ -20,6 +20,7 @@ import com.l2fprod.common.propertysheet.Property; ...@@ -20,6 +20,7 @@ import com.l2fprod.common.propertysheet.Property;
import jcl.data.mask.Mask; import jcl.data.mask.Mask;
import jcl.utils.MemoryFlush; import jcl.utils.MemoryFlush;
import jcl.utils.Images.StreamedImageReaderWrapper;
import jcl.utils.exceptions.MethodNotImplementedException; import jcl.utils.exceptions.MethodNotImplementedException;
/** /**
...@@ -129,33 +130,39 @@ public class RawImage implements Serializable, MemoryFlush ...@@ -129,33 +130,39 @@ public class RawImage implements Serializable, MemoryFlush
* Represents the maximum possible value in the image format * Represents the maximum possible value in the image format
* </p> * </p>
*/ */
private double maxValue = 0; private double maxValue = 0;
/** min values for each channels */
protected double[] minValues = null;
/** max values for each channels */
protected double[] maxValues = null;
/** /**
* <p> * <p>
* Represents number of bands in the image. * Represents number of bands in the image.
* </p> * </p>
*/ */
private int nbBands = 0; private int nbBands = 0;
/** /**
* <p> * <p>
* Represents the maximum representative number of bit in the image * Represents the maximum representative number of bit in the image
* </p> * </p>
*/ */
private short nBitPerPixel = 0; private short nBitPerPixel = 0;
/** /**
* Proprietes de l'image * Proprietes de l'image
*/ */
public Vector<Property> properties = new Vector<Property>(); public Vector<Property> properties = new Vector<Property>();
/** /**
* <p> * <p>
* Represents the resolution (in meters/pixel) of the image (0 = X, 1 = Y). * Represents the resolution (in meters/pixel) of the image (0 = X, 1 = Y).
* </p> * </p>
*/ */
private double[] resolution = null; private double[] resolution = null;
/** /**
* <p> * <p>
...@@ -1192,7 +1199,7 @@ public class RawImage implements Serializable, MemoryFlush ...@@ -1192,7 +1199,7 @@ public class RawImage implements Serializable, MemoryFlush
*/ */
private double[][][] load(ImageReadParam param) private double[][][] load(ImageReadParam param)
{ {
System.out.println(">>>>>>>>>>>>>>>>>>> IN ><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
int x; int x;
int y; int y;
int w; int w;
...@@ -2095,6 +2102,64 @@ public class RawImage implements Serializable, MemoryFlush ...@@ -2095,6 +2102,64 @@ public class RawImage implements Serializable, MemoryFlush
{ {
this.workfilename = workfilename; this.workfilename = workfilename;
} }
/**
* Return the minimum value for each channel
* @return the minimums
*/
public double[] getMinValues() {
if(minValues == null) {
computeMinMax();
}
return minValues;
}
/**
* Set the minimum value for each channel
* @param minValues
* the minimums
*/
public void setMinValues(double[] minValues) {
this.minValues = minValues;
}
/**
* Return the maximum value for each channel
* @return the maximums
*/
public double[] getMaxValues() {
if(maxValues == null) {
computeMinMax();
}
return maxValues;
}
/**
* Set the maximum value for each channel
* @param maxValues
* the maximums
*/
public void setMaxValues(double[] maxValues) {
this.maxValues = maxValues;
}
/**
* Compute teh min/max values per channel
*/
private void computeMinMax() {
StreamedImageReaderWrapper reader = new StreamedImageReaderWrapper(filename);
long allocatedMemory = (Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory());
long presumableFreeMemory = Runtime.getRuntime().maxMemory() - allocatedMemory;
// we just tack the 2/3rd of the memory available;
presumableFreeMemory *= 0.05;
try {
reader.setMaxRAM(presumableFreeMemory);
} catch (IOException e) {
e.printStackTrace();
}
minValues = reader.getMinValues();
maxValues = reader.getMaxValues();
}
@Override @Override
public void flushMemory() throws MethodNotImplementedException public void flushMemory() throws MethodNotImplementedException
......
...@@ -178,13 +178,13 @@ public class BufferedImageHelper { ...@@ -178,13 +178,13 @@ public class BufferedImageHelper {
for(int x = 0 ; x < imageWidth ; x++) { for(int x = 0 ; x < imageWidth ; x++) {
double[] pixel = null; double[] pixel = null;
try { // try {
pixel = reader.getPixel(x+imageX, y+imageY); pixel = reader.getPixel(x+imageX, y+imageY);
} catch (ArrayIndexOutOfBoundsException e) { // } catch (ArrayIndexOutOfBoundsException e) {
System.out.println(x+","+y+" in : "+imageX+","+imageY+" - "+imageWidth+","+imageHeight); // System.out.println(x+","+y+" in : "+imageX+","+imageY+" - "+imageWidth+","+imageHeight);
e.printStackTrace(); // e.printStackTrace();
//
} // }
int rgb = 0; int rgb = 0;
if (maxValues != null && minValues != null) { if (maxValues != null && minValues != null) {
rgb = new Color(rescaleColor(pixel[r], 0, maxValues[r]), rgb = new Color(rescaleColor(pixel[r], 0, maxValues[r]),
...@@ -201,6 +201,16 @@ public class BufferedImageHelper { ...@@ -201,6 +201,16 @@ public class BufferedImageHelper {
return result; return result;
} }
/**
* Rescale a value from a given range to 0-255
* @param value
* the value to recale
* @param min
* the min value of the range
* @param max
* the max value of the range
* @return the rescaled value
*/
private static int rescaleColor(double value, double min, double max) { private static int rescaleColor(double value, double min, double max) {
if (value < min) { if (value < min) {
value = min; value = min;
...@@ -209,4 +219,51 @@ public class BufferedImageHelper { ...@@ -209,4 +219,51 @@ public class BufferedImageHelper {
} }
return (int) ((255 * (value - min)) / (max - min)); return (int) ((255 * (value - min)) / (max - min));
} }
/**
* Clone a bufferedImage.
* @param bi
* the bufferedImage to copy
* @return the copy of the bufferedImage
*/
public static BufferedImage deepCopy(BufferedImage bi) {
if (bi == null)
return null;
ColorModel cm = bi.getColorModel();
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
WritableRaster raster = bi.copyData(bi.getRaster().createCompatibleWritableRaster());
return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
/**
* Compute the average image from two images
* For each pixel it's channels values is the average of
* the channel value of the two images.
* The two image have to have the same dimensions
* @param image1
* the first image
* @param image2
* the second image
* @return the average of image1 and image2
*/
public static BufferedImage averagedBufferedImage(BufferedImage image1, BufferedImage image2) {
if (image1.getHeight() != image2.getHeight() ||
image1.getWidth() != image2.getWidth()) {
throw new IndexOutOfBoundsException("the BufferedImage shouyld have the same dimensions");
}
BufferedImage result = new BufferedImage(image1.getWidth(), image1.getHeight(),
BufferedImage.TYPE_INT_RGB);
for(int x = 0 ; x < image1.getWidth() ; x++) {
for(int y = 0 ; y < image1.getHeight() ; y++) {
Color c1 = new Color(image1.getRGB(x, y));
Color c2 = new Color(image2.getRGB(x, y));
Color c = new Color((c1.getRed()+c2.getRed())/2,
(c1.getGreen()+c2.getGreen())/2,
(c1.getBlue()+c2.getBlue())/2);
result.setRGB(x, y, c.getRGB());
}
}
return result;
}
} }
...@@ -49,6 +49,8 @@ public class BufferedImageViewer extends ImageViewer { ...@@ -49,6 +49,8 @@ public class BufferedImageViewer extends ImageViewer {
* - not used if instantiate directly with a BufferedImage */ * - not used if instantiate directly with a BufferedImage */
private short[][][] raster = null; private short[][][] raster = null;
BufferedImageViewer comparedImage = null;
/** /**
* Construct a viewer from a raw BufferedImage. * Construct a viewer from a raw BufferedImage.
...@@ -190,6 +192,10 @@ public class BufferedImageViewer extends ImageViewer { ...@@ -190,6 +192,10 @@ public class BufferedImageViewer extends ImageViewer {
+ mask.getOverallCarinality() + " != " + mask.getOverallCarinality() + " != "
+ (this.getRealImageWidth() + "x" + this.getRealImageHeight()) + ")"); + (this.getRealImageWidth() + "x" + this.getRealImageHeight()) + ")");
} }
if (comparedImage != null) {
comparedImage.addMask(mask);
}
} }
private void applyMask() { private void applyMask() {
...@@ -211,16 +217,15 @@ public class BufferedImageViewer extends ImageViewer { ...@@ -211,16 +217,15 @@ public class BufferedImageViewer extends ImageViewer {
rgbBands[1] = 1; rgbBands[1] = 1;
rgbBands[2] = 2; rgbBands[2] = 2;
rescale = null; rescale = null;
comparedImage = null;
} }
@Override @Override
public BufferedImage getScreenImage(int x, int y, int width, int height, double zoomRate) { public BufferedImage getScreenImage(int x, int y, int width, int height, double zoomRate, boolean saved) {
if(width <= 0 || height <= 0) { if(width <= 0 || height <= 0) {
return null; return null;
} }
realX = x;
realY = y;
// we reverse compute the coordinates in the original image // we reverse compute the coordinates in the original image
int updatedWidth = (int) Math.ceil(width / zoomRate); int updatedWidth = (int) Math.ceil(width / zoomRate);
int updatedHeight = (int) Math.ceil(height / zoomRate); int updatedHeight = (int) Math.ceil(height / zoomRate);
...@@ -232,11 +237,11 @@ public class BufferedImageViewer extends ImageViewer { ...@@ -232,11 +237,11 @@ public class BufferedImageViewer extends ImageViewer {
if (updatedHeight + y > mSourceImage.getHeight()) { if (updatedHeight + y > mSourceImage.getHeight()) {
updatedHeight = mSourceImage.getHeight() - y; updatedHeight = mSourceImage.getHeight() - y;
} }
mScreenImage = mSourceImage.getSubimage(x, y, updatedWidth, updatedHeight); BufferedImage screen = mSourceImage.getSubimage(x, y, updatedWidth, updatedHeight);
// we apply the rescale operation // we apply the rescale operation
if (rescale != null) { if (rescale != null) {
mScreenImage = this.rescale.filter(mScreenImage, null); screen = this.rescale.filter(screen, null);
} }
// we apply the mask to image // we apply the mask to image
if (mask != null) { if (mask != null) {
...@@ -245,14 +250,30 @@ public class BufferedImageViewer extends ImageViewer { ...@@ -245,14 +250,30 @@ public class BufferedImageViewer extends ImageViewer {
// we update the source image to crop to the screen size // we update the source image to crop to the screen size
AffineTransform trans = AffineTransform.getScaleInstance(zoomRate, zoomRate); AffineTransform trans = AffineTransform.getScaleInstance(zoomRate, zoomRate);
AffineTransformOp op = new AffineTransformOp(trans, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); AffineTransformOp op = new AffineTransformOp(trans, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
mScreenImage = op.filter(this.mScreenImage, null); screen = op.filter(screen, null);
//mScreenImage = op.filter(this.mScreenImage, null).getSubimage(0, 0, width, height); //mScreenImage = op.filter(this.mScreenImage, null).getSubimage(0, 0, width, height);
return mScreenImage; if (saved) {
realX = x;
realY = y;
mScreenImage = screen;
}
if (comparedImage != null) {
BufferedImage scr2 = comparedImage.getScreenImage(x, y, width, height, zoomRate, saved);
return BufferedImageHelper.averagedBufferedImage(screen, scr2);
}
return screen;
} }
@Override @Override
public BufferedImage getScreenImage() { public BufferedImage getScreenImage() {
if (comparedImage != null) {
BufferedImage scr2 = comparedImage.getScreenImage();
return BufferedImageHelper.averagedBufferedImage(mScreenImage, scr2);
}
return mScreenImage; return mScreenImage;
} }
...@@ -274,7 +295,31 @@ public class BufferedImageViewer extends ImageViewer { ...@@ -274,7 +295,31 @@ public class BufferedImageViewer extends ImageViewer {
this.rescale = new RescaleOp(this.getContrastValue(), this.getBrightnessValue(), null); this.rescale = new RescaleOp(this.getContrastValue(), this.getBrightnessValue(), null);
this.mScreenImage = this.rescale.filter(this.mScreenImage, null); this.mScreenImage = this.rescale.filter(this.mScreenImage, null);