Jump to content
  • Advertisement
Sign in to follow this  
JuliusDegutis

Java AffineTransform

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, maybe I writing in good place, if not - don't be mad on me smile.png
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;
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!