private void applyTransform(BufferedImage sourceImage, BufferedImage destinationImage, PerspectiveTransform transform) {
        for(int x = 0; x < destinationImage.getWidth(); x++) {
            for(int y = 0; y < destinationImage.getHeight(); y++) {
                try {
                    final Point2D sourcePoint = new Point2D.Double(x, y);
                    final Point2D destPoint = new Point2D.Double();
                    transform.inverseTransform(sourcePoint, destPoint);

                    int destPointX = (int)destPoint.getX();
                    int destPointY = (int)destPoint.getY();

                    if (destPointX < 0 ||
                            destPointY < 0 ||
                            destPointX >= sourceImage.getWidth() ||
                            destPointY >= sourceImage.getHeight()) {
                        continue;
                    }

                    final int color = sourceImage.getRGB(destPointX, destPointY);
                    destinationImage.setRGB((int)sourcePoint.getX(), (int)sourcePoint.getY(), color);
                } catch (Exception e) {
                    throw new RuntimeException("Error transforming image!", e);
                }
            }
        }
    }