Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fix distorted round
#11
(10-26-2020, 10:24 AM)Ofnuts Wrote:
(10-26-2020, 07:02 AM)Ottia Tuota Wrote: So, for example if you choose some four points A,B,C,D from the circumference of your clock face, and corresponding four points P,Q,R,S from a circle, the created transformation should be the one needed.

The problem is that its difficult to figure out the 4 points that should correspond to 4 known points on the final correct circle. It is however possible to indicate 4 points on the distorted circle, but nothing more. So the question is, given 4 points, is there a way to compute the Projective transform (is this transform unique? additional constraints are possible to make it unique, such as keeping the distance between two points identical, or keepin the orientation between two given points, or both)) than puts them on a circle? If I have this transform, I can figure out a way to use it with gimp_item_transform_perspective().

I was thinking of the original problem. There you yourself chose four points from the dial (3,6,9,12 hours). Those could serve as A,B,C,D. On a true circle we can choose four points P,Q,R,S separated by angles of 90 degrees. This information determines the projective transformation uniquely.

Of your more general question, I cannot say anything.

But: I never knew that there is a procedure such as gimp_item_transform_perspective() which can be called from a plugin! (I assume it indeed can be called from a plugin? I haven't tried.)  The problem with it is that it uses the corners of the bounding box, not any general 4 points.

What is even more interesting is that now I noticed another internal procedure called gimp_item_transform_matrix! It takes as input 9 floats, the elements of a 3x3 matrix. Procedure browser says:

"This procedure transforms the specified item.

The transformation is done by assembling a 3x3 matrix from the coefficients passed."

I guess this is the usual 3x3 matrix that is attached to any projective transformation. This seem to mean that given a suitable matrix (the 9 floats), one can call the procedure gimp_item_transform_matrix to perform the corresponding transformation!

On the other hand, my Python function make_projective_map, given points A,B,C,D and P,Q,R,S, computes the transformation by first computing the 3x3 matrix.

This now suggests that the following could be possible:
  1. Suppose we are given points A,B,C,D and P,Q,R,S. We want to perform a projective transformation where A,B,C,D -> P,Q,R,S.
  2. From my Python function make_projective_map extract that piece of code which computes the 3x3 matrix of the desired transformation.
  3. Feed that 3x3 matrix to the procedure gimp_item_transform_matrix.
I wonder if this is true. I must try it some day when I find the time. I vision that we perhaps could write a plugin that takes as input two 4-anchor paths (these give the points A,B,C,D and P,Q,R,S) and some item (=?) and performs the transformation on the item. This plugin would be the Perspective transform tool in a different disguise.

I already know that there will be difficulties: the infinities that come with projective transformations. We shall see.
Reply


Messages In This Thread
fix distorted round - by denzjos - 10-23-2020, 08:47 AM
RE: fix distorted round - by rich2005 - 10-24-2020, 08:44 AM
RE: fix distorted round - by denzjos - 10-24-2020, 11:06 AM
RE: fix distorted round - by Ofnuts - 10-24-2020, 02:38 PM
RE: fix distorted round - by denzjos - 10-24-2020, 05:31 PM
RE: fix distorted round - by Ofnuts - 10-25-2020, 05:37 PM
RE: fix distorted round - by denzjos - 10-25-2020, 06:29 PM
RE: fix distorted round - by Ottia Tuota - 10-26-2020, 07:02 AM
RE: fix distorted round - by Ofnuts - 10-26-2020, 10:24 AM
RE: fix distorted round - by Ottia Tuota - 10-26-2020, 05:09 PM
RE: fix distorted round - by Ottia Tuota - 10-30-2020, 07:26 AM
RE: fix distorted round - by denzjos - 10-26-2020, 08:01 AM
RE: fix distorted round - by Ottia Tuota - 10-28-2020, 05:14 PM

Forum Jump: