Sign in to follow this  

Java AffineTransform

This topic is 2047 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 [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
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.

[CODE]
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;
}
[/CODE]

Share this post


Link to post
Share on other sites

This topic is 2047 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this