Has anyone been able to use the ImageMagick or GraphicsMagick plugins from MBS to apply perspective changes to an image, in order to straighten walls, for example?
Thanks.
It may be worth looking at.
I’m going the other way… need to find automatically or manually (click click click), the vertices of one of the faces of the cube, and turn it back into a square.
I played around with it, though I now use my in-house system as it gives me more precise shape control.
i made a tool for it in b4j long ago.
main part if 4 points of the image was selected.
the linear methods get in mu just a value from 0 to 1
(other Basic)
Sub Render(ImA As Image,ImB As Image,Width As Float,Height As Float)
Dim x As Float
Dim y As Float
Dim a As Float
Dim b As Float
Dim pa As Point
Dim pb As Point
Dim pc As Point
Dim Pixel As Int
For x=0.0 To Width-1.0
a=x / (Width-1.0)
pa=Linear(Point(1),Point(2),a)
pb=Linear(Point(4),Point(3),a)
For y=0 To Height-1.0
b=y / (Height-1.0)
pc=Linear(pa,pb,b)
Pixel=ImA.GetPixel(pc.x,pc.y)
.. write x,y pixel into new image
Next
Next
End Sub
Sub Linear(p1 As Point, p2 As Point, mu As Float) As Point
Dim pn As Point
pn.x = LinearInterpolate(p1.x,p2.x,mu)
pn.y = LinearInterpolate(p1.y,p2.y,mu)
Return pn
End Sub
Sub LinearInterpolate( y1 As Float, y2 As Float, mu As Float) As Float
Dim f As Float
f=(y1*(1.0-mu)+y2*mu)
Return f
End Sub
1 Like
Thank you.
That may be very useful!
the idea behind is that the output image width runs from mu value 0 to 1
along the upper line from point 1 to 2 and the bottom line from point 4 to 3.
then the output image height from mu value 0 to 1 you get the position from up to down.