affinetransform

Changing the min and max value of JSlider depanding on condition

為{幸葍}努か 提交于 2020-01-14 10:31:13
问题 I'm creating a Swing GUI in Netbeans. The purpose of this GUI is to open an (buffered)image (in a JLabel as icon) and apply Affine transforms on it. Now there are 4 transforms that I'm doing as follows. Now, each transform requires two sliders to change the X and Y value, except that of rotate, which will require only one. I did it this way since its much better than having to do four tabs for all 4 types of transforms. Also I want it to be such that , for example, if an image is rotated, the

java rotate rectangle around the center

北战南征 提交于 2020-01-13 09:35:10
问题 I would like to rotate a rectangle around its center point and it should remain in the place that it is supposed be drawn and rotate in that space this is my code: AffineTransform transform = new AffineTransform(); transform.rotate(Math.toRadians(45),rectangle.width/2, rectangle.height/2); Shape transformed = transform.createTransformedShape(rectangle); g2.fill(transformed) the rectangle is rotated but it is drawn at a different part of the screen, how can I correct this? 回答1: I haven't tried

How to bend an Image in java

会有一股神秘感。 提交于 2020-01-13 06:00:29
问题 Is there any way to bend a BufferedImage in Java? I thought that if I crop the image into smaller pieces and rotate them then I would essentially bend the image, but it doesn't seem to work. Here is the method I created: /** * This is a recursive method that will accept an image the point where the bending will start and the point where the bending will end, as well as the angle of bending * * @param original:the original image * @param startingPoint: the point where the bending should start

How to find affine transformation matrix between two sets of 3D points?

左心房为你撑大大i 提交于 2020-01-11 14:22:14
问题 I need to register some 3D facial landmarks given for each frame of a video. For this task, I am trying to find out a transformation matrix between a few landmark coordinates given for the consecutive frames. For example, 3D coordinates of 3 landmarks in frame 1 and frame 2 are given as: frame1 = [2 4 15; 4 15 14; 20 11 7] frame2 = [16 5 12; 5 7 9; 11 6 19] I have tried using imregtform function provided by matlab and ABSOR tool for matlab. tform = imregtform(frame1, frame2, 'affine',

Homography and Affine Transformation

廉价感情. 提交于 2020-01-10 14:12:12
问题 Hi i am a beginner in computer vision and i wish to know what exactly is the difference between a homography and affine tranformation, if you want to find the translation between two images which one would you use and why?. From papers and definitions I found online, I am yet to find the difference between them and where one is used instead of the other. Thanks for your help. 回答1: I have set it down in the terms of a layman. Homography A homography, is a matrix that maps a given set of points

Java Class Cast Exception java.awt.geom.Path2D.Double

扶醉桌前 提交于 2020-01-05 02:46:32
问题 I've been getting this class cast exception when trying to to implement an AffineTransform. Call to AffineTransform: public Shape moveToAndRotate(double x, double y, double theta) { double cx = getBounds2D().getCenterX(); double cy = getBounds2D().getCenterY(); at.translate(cx, cy); at.translate(x, y); at.rotate(Math.toRadians(theta)); at.translate(-cx, -cy); return at.createTransformedShape(yingYang); } This is resides in a custom shape class (YingYang). public class YingYang implements

storing transformed BufferedImage in Java

萝らか妹 提交于 2020-01-04 06:48:49
问题 In Java, instead of using photoshop to transform my images(that I use in the program), I want to use code to transform and save them. I have created an AffineTransform object "at" and called the rotate() method. I have a BufferedImage called "image". I can draw the image on the screen with the desired transformation with this code: g2d.drawImage(image, at, null); What I want to do is to store the combination of at and image in a new BufferedImage image2. How can I do this so that g2d

Problems rotating BufferedImage

冷暖自知 提交于 2020-01-03 07:23:08
问题 I have some problems with rotating images in Java using the AffineTransform class. I have the following method for creating a rotated (90 degrees) copy of an image: private BufferedImage createRotatedCopy(BufferedImage img, Rotation rotation) { int w = img.getWidth(); int h = img.getHeight(); BufferedImage rot = new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB); double theta; switch (rotation) { case CLOCKWISE: theta = Math.PI / 2; break; case COUNTERCLOCKWISE: theta = -Math.PI / 2; break;

Image not at proper place after rotating (graphics)

妖精的绣舞 提交于 2019-12-31 02:18:09
问题 I am trying to display two rotating wheels with diameter 512untis at different rates but i am not able to remove the previous drawn image graphics and set the rotated graphics at the correct position. For now i am doing a rotation with arbitrary angle. I tried affineTransform and got the rotations but it was weird like all pixels spread away. Im using a while loop with thread.sleep(). The following is the code : //The drawSmallCircle and drawBigCircle return two images. class MyFramePart2

Create transform to map from one rectangle to another?

回眸只為那壹抹淺笑 提交于 2019-12-30 04:33:30
问题 What is the simplest way to create AffineTransform which maps coordinates from one rectangle to another (float/double rectangles are given)? UPDATE 1 Rectangles can be absolutely different. For example [(0,0)-(1,1)] and [(150,-14)-(-1000,-14.1)]. And transformation should transform uniformly. For example, rectangle corners should be transformed one to one. For example coordinates (0,0) should turn to (150,-14). UPDATE 2 I need AffineTransform object, not just calculation. Because I want to