使用Java将多边形伸展到其他多边形 [英] Stretching Polygon to other Polygon with Java
问题描述
我的问题是我有一个呈现小视角的矩形,我想将其拉伸回来,再次呈现为矩形。
表示它在视觉上,我目前在我的图像内有像红色的形状,我有4 Points
(这个形状的每个角)。因此,我想要像蓝色的形状,我已经有 Rectangle
对象。
我在想如果有一种方法可以复制多边形并将其拉伸为另一个多边形。我找到了一些适用于Android的设置(setPolyToPoly),但是我找不到像java这样的东西。
是否有一些引用或代码示例执行此操作,或者可能一些想法如何解决这个问题?我想我明白你需要什么:一种所谓的透视变换,可以应用于图像。 Java具有内置的 AffineTransform ,但仿射变换总是保留线条的平行性,所以你不能使用它。
现在,如果您搜索网络中的Java透视变换,您将找到许多选项,例如JavaFX PerspectiveTransform , JAI PerspectiveTransform 。如果您只需要拉伸图像,则还可以使用JHLabs PerspectiveFilter 并在那里也是其他选项。
My problem is that I have a rectangle presented with a small perspective, and I would like to stretch it back to be presented as a rectangle again.
To represent it visually, I currently have within my image something like the red shape, and I have 4 Points
(each corner of this shape). As result I would like to have something like the blue shape, and I already have the Rectangle
object for it.
I was wondering if there is a method to copy a polygon and draw it as another polygon stretched. I found something for Android (setPolyToPoly), but I couldn't find something like this for java.
Is there some reference or code sample that performs this operation, or maybe some idea how can I solve this problem?
I think I understand what you need: a so-called perspective transformation that can be applied to an image. Java has the built-in AffineTransform, but an affine transform always preserves the "parallelness" of lines, so you cannot use that.
Now if you search the web for "java perspective transformation", you will find lots of options like the JavaFX PerspectiveTransform, the JAI PerspectiveTransform. If you only need to stretch images, you can also use the JHLabs PerspectiveFilter and there are other options as well.
这篇关于使用Java将多边形伸展到其他多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!