affinetransform

Rotating an image matrix around its center in MATLAB

北城余情 提交于 2019-12-05 03:14:44
问题 Assume I have a 2x2 matrix filled with values which will represent a plane. Now I want to rotate the plane around itself in a 3-D way, in the "z-Direction". For a better understanding, see the following image: I wondered if this is possible by a simple affine matrix, thus I created the following simple script: %Create a random value matrix A = rand*ones(200,200); %Make a box in the image A(50:200-50,50:200-50) = 1; Now I can apply transformations in the 2-D room simply by a rotation matrix

AffineTransform without transforming Stroke?

大兔子大兔子 提交于 2019-12-05 01:35:56
When using the Graphics2D scale() function with two different parameters (scaling by different ratios in x- and y-direction), everything drawn later on this Graphics2D object is scaled too. This has the strange effect that lines drawn in one direction are thicker than those in another direction. The following program produces this effect, it shows this window: public class StrokeExample extends JPanel { public void paintComponent(Graphics context) { super.paintComponent(context); Graphics2D g = (Graphics2D)context.create(); g.setStroke(new BasicStroke(0.2f)); int height = getHeight(); int

How to bend an Image in java

一曲冷凌霜 提交于 2019-12-04 15:04:16
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 * @param endingPoint: the point where the bending should end * @param radiands: the angle * @return the

Java - Does subpixel line accuracy require an AffineTransform?

南笙酒味 提交于 2019-12-04 10:41:46
问题 I've never worked with Java drawing methods before, so I decided to dive in and create an analog clock as a PoC. In addition to the hands, I draw a clock face that includes tick marks for minutes/hours. I use simple sin/cos calculations to determine the position of the lines around the circle. However, I've noticed that since the minute tick-marks are very short, the angle of the lines looks wrong. I'm certain this is because both Graphics2D.drawLine() and Line2D.double() methods cannot draw

How to estimate 2D similarity transformation (linear conformal, nonreflective similarity) in OpenCV?

故事扮演 提交于 2019-12-04 09:42:54
问题 I'm trying to search a specific object in input images by matching SIFT descriptors and finding the transformation matrix by RANSAC. The object can only be modified in scene by similarity transform in 2D space (scaled, rotated, translated), so I need to estimate 2x2 transform matrix instead of 3x3 homography matrix in 3D space. How can I achieve this in OpenCV? 回答1: You can use estimateRigidTransform (I do not know whether it is RANSAC, the code at http://code.opencv.org/projects/opencv

Affine transformation matrix offset

孤街醉人 提交于 2019-12-04 04:32:14
This has been killing me the last few days. Not even kidding, but I've been really stressing over this trying to solve it. I am currently trying to use affine transformation matrices to create an isometric projection in HTML5. I receive a tile which is a square that is rotated 45 degrees (essentially a square diamond on a square canvas). I then scale one of the axis' depending on if the there is a delta in the x or y direction. I then skew the axis by a factor to fit. Then, I negate the initial rotation by rotating it back by -45 degrees. Currently, my affine matrix is: // note: the difference

AffineTransform truncates image

♀尐吖头ヾ 提交于 2019-12-04 02:09:30
问题 I have an image and I have to rotate it by 45, 90, 135, 180 degrees. What I am doing: try { BufferedImage src = ImageIO.read(new File("src.png")); double ang = Math.toRadians(90); AffineTransform t = new AffineTransform(); t.setToRotation(ang, src.getWidth() / 2, src.getHeight() / 2); AffineTransformOp op = new AffineTransformOp(t, null); BufferedImage dst = new BufferedImage(src.getWidth(), src.getHeight(), src.getType()); op.filter(src, dst); ImageIO.write(dst, "png", new File("output.png")

Rotating an image matrix around its center in MATLAB

限于喜欢 提交于 2019-12-03 17:18:54
Assume I have a 2x2 matrix filled with values which will represent a plane. Now I want to rotate the plane around itself in a 3-D way, in the "z-Direction". For a better understanding, see the following image: I wondered if this is possible by a simple affine matrix, thus I created the following simple script: %Create a random value matrix A = rand*ones(200,200); %Make a box in the image A(50:200-50,50:200-50) = 1; Now I can apply transformations in the 2-D room simply by a rotation matrix like this: R = affine2d([1 0 0; .5 1 0; 0 0 1]) tform = affine3d(R); transformed = imwarp(A,tform);

affine transform in PIL python

旧街凉风 提交于 2019-12-03 14:55:22
问题 I have problems with the im.transform method in PIL python library. I thought I figured out the logic of parameters, A to F, however, the resulting image gets rotated in the wrong direction and cut off although all four corners calculated by the bellow function have correct positive values. Could anybody give me formulas to calculate affine parameters (A to F) from three identical points in both coordinate systems? def tran (x_pic, y_pic, A, B, C, D, E, F): X = A * x_pic + B * y_pic + C Y = D

Java - Does subpixel line accuracy require an AffineTransform?

久未见 提交于 2019-12-03 07:31:59
I've never worked with Java drawing methods before, so I decided to dive in and create an analog clock as a PoC. In addition to the hands, I draw a clock face that includes tick marks for minutes/hours. I use simple sin/cos calculations to determine the position of the lines around the circle. However, I've noticed that since the minute tick-marks are very short, the angle of the lines looks wrong. I'm certain this is because both Graphics2D.drawLine() and Line2D.double() methods cannot draw with subpixel accuracy. I know I can draw lines originating from the center and masking it out with a