Hello Mike,
Anthony and I were just discussing that last night. He has a verbose
setting for use with -distort perspective that will output the
transformation coefficients, which then can be reused with -distort
perspectiveprojection
He sent me a while back the following example, but I have not been
able to reproduce the text/coefficient output.
For example, 2-point affine (fallback from perspective!)
convert rose: -virtual-pixel black -set option:distort:verbose 1 \
-distort perspective '0,0,10,5 0,45,5,20' x:
Outputs to STDERR
Affine Reverse Map
-fx 'xx=+2.700000*i +0.900000*j -31.500000;
yy=-0.900000*i +2.700000*j -4.500000; p{xx,yy}'
Affine Forward Map
-distort AffineProjection \
'0.333333,0.111111,-0.111111,0.333333,10,5'
I expect similar output for a 4 point perspective - but get the
perspective coefficients rather than the affine fall back ones.
For example from his Distort Examples page:
convert building.jpg -matte -virtual-pixel transparent \
-set option:distort:verbose 1 \
-distort Perspective \
'7,40 4,30 4,124 4,123 85,122 100,123 85,2 100,30' \
building_pers.png
should output to stderr the coefficients, but I cannot get them to
list to the terminal even with a redirect. I keep getting an error
message something like:
"convert: option requires an argument `-distort' @
wand/convert.c/ConvertImageCommand/1147"
I tried both:
convert building.jpg -matte -virtual-pixel transparent \
-set option:distort:verbose 1 \
-distort Perspective \
'7,40 4,30 4,124 4,123 85,122 100,123 85,2 100,30' \
building_pers.png 2> tmp.txt
and
str=`convert building.jpg -matte -virtual-pixel transparent \
-set option:distort:verbose 1 \
-distort Perspective \
'7,40 4,30 4,124 4,123 85,122 100,123 85,2 100,30' \
building_pers.png 2>&1`
echo $str
Perhaps I misunderstand how to do this.
So I will forward him this message (as he is on his weekend now).
When he gets it he can clarify for you (and me) further.
HOWEVER, I doubt that computing the coefficients from the points
takes that much time that you would really notice it (at least not on
a single frame). Perhaps on hundreds of frames. But it should be
insignificant compared to all the computations for transforming all
the pixel data.
Nevertheless, that was at least part of the reason to have the
-distort perspectiveprojection
Fred
>Greetings.
>
>I have a program that incorporates ImageMagick to do a perspective
>transformation on a single image. I give it the requisite
>coordinates and it works extraordinarily well.
>
>Now, I need to move to the next level. I have a series of images,
>let's call it a movie, on which I would like to do a perspective
>transformation of each frame. The coordinates will be the same for
>each frame as the camera and the reference points are fixed. As it
>takes some time to compute the transformation matrix, I was
>wondering if there was a built-in way to calculate the matrix on the
>first frame, then retain the matrix and use it on each successive
>frame to improve efficiency.
>
>I see from the documentation
>(http://www.imagemagick.org/script/command-line-options.php#distort)
>that I can use the -verbose setting to get the internal coefficients
>and an -fx equivalent. However, I am not sure this -fx equivalent
>would actually save on computation time.
>
>Could anyone enlighten me as to the most efficient way of doing this
>identical perspective transformation on a series of images? Is
>calculating the transformation matrix even a significant amount of
>time?
>
>Thank you very much,
>Mike
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users