• 15
• 15
• 11
• 9
• 10

# Java AffineTransform

This topic is 2146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, maybe I writing in good place, if not - don't be mad on me
I am trying to make motion blur to image. Achieved horizontal or vertical blurs, but I need to make blur by angle. So I think I could rotate image, blur it on horizontal axis, and rotate it to original position. Am I right? For this I using AffineTransform, bet I think I using it bad, because can't get wanted result. For blur effect using convolution matrix. Rotation angle getting from slider.
I think I don't understand how to rotate to original position (undo first rotation). Or maybe there is another way to solve my task.

 private void blurringImage() { BufferedImageOp blur = new ConvolveOp(new Kernel(3, 3, blurKernel)); System.out.println(angle); double rotate1 = Math.toRadians(angle); double rotate2 = Math.toRadians(360 - angle); System.out.println(rotate1 + " " + rotate2 + " " + (rotate1 + rotate2)); AffineTransform tx = new AffineTransform(); dest = source; //first rotate to achieve angle tx.rotate(rotate1, source.getWidth() / 2, source.getHeight() / 2); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); dest = op.filter(dest, null); //chosing blur intensitivity and blur'ing if (intensity == 1) { blur = new ConvolveOp(new Kernel(7, 1, blurKernel0)); } if (intensity == 2) { blur = new ConvolveOp(new Kernel(11, 1, blurKernel1)); } if (intensity == 3) { blur = new ConvolveOp(new Kernel(15, 1, blurKernel2)); } if (intensity == 4) { blur = new ConvolveOp(new Kernel(19, 1, blurKernel3)); } dest = blur.filter(dest, null); //rotate to original position tx.rotate(rotate1, source.getWidth() / 2, source.getHeight() / 2); op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); dest = op.filter(dest, null); rightImage = (Image) dest; }