Sorry, but I still don't understand. Why do you want to do this? What is the effect on the cylinder and or image texture? I am missing the point of this. The only thing that seems reasonable to me is a compression of the cylinder, if at all. What is the point of some other kind of y displacement other than a linear compression? I am not following you. Please clarify. Thanksanthony wrote:as y is only dependant on x, all pixels of constant x will have the the same value. thus no compression only displacement!!! It is like -wave just displacing to a circlar curve, rather than to a sine curve!
Help with composite images
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with composite images
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Help with composite images
Look at the original example that started this whole discussion!
The image was compressed in the X direction, and displaced in a -wave like function in the Y direction.
The Y displacement however is not a sin curve such as -wave, but in an elliptical arc which is what I was giving. You figured out the X compression, I figured out the Y displacement!
The image was compressed in the X direction, and displaced in a -wave like function in the Y direction.
The Y displacement however is not a sin curve such as -wave, but in an elliptical arc which is what I was giving. You figured out the X compression, I figured out the Y displacement!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with composite images
OK, I think I understand now. Sorry to be so slow at catching on. You are trying to account for the (orthographic) tilt of the cylinder so that the top and bottom of the image are curved. Your formula may not be an exact representation, but it may look similar. I will look into this. Thanks.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Help with composite images
For orthographic projection a circular arc converted into an ellipse by a 50% reduction in displacement will produce a correct orthographic cylinder. Cylinders are a lot easier than cubes
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with composite images
Seems to be working out, but the details are taking a while to work out. I think I have the vertical mode worked out in my test script. Still have to formalize it all. I have tried to approximate the tilt with a rotation parameter, so that the arc is scaled appropriately (as sin(tilt)) and the length (as cos(tilt)) also. I also had to pad and then potentially remove excess as the curved part now displaces more than the length shrinks for small angles. I also implemented a 2 sided (only) trim, which I will note at the bottom.
Here are some test results:
tilt=0 degrees
tilt=11 degrees
tilt=22 degrees
tilt=45 degrees
Here is how I did a 2-sided trim, top and bottom only, (assuming background=$bgcolor=black all around and a safecolor=$scolor=white):
convert \( $infile -bordercolor $bgcolor -border 1x0 \) \
-size 1x1 xc:"$scolor" -gravity west -composite \
-size 1x1 xc:"$scolor" -gravity east -composite \
-trim +repage -bordercolor $bgcolor -shave 1x0 $outfile
Here are some test results:
tilt=0 degrees
tilt=11 degrees
tilt=22 degrees
tilt=45 degrees
Here is how I did a 2-sided trim, top and bottom only, (assuming background=$bgcolor=black all around and a safecolor=$scolor=white):
convert \( $infile -bordercolor $bgcolor -border 1x0 \) \
-size 1x1 xc:"$scolor" -gravity west -composite \
-size 1x1 xc:"$scolor" -gravity east -composite \
-trim +repage -bordercolor $bgcolor -shave 1x0 $outfile
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Help with composite images
I would also suggest you generate a seperate destination image to the source image so that teh new image can be appropriatally smaller in width and longer in height.
You can see the technique of using a separate destination image from any -verbose output for the 'plus' +distort.
It also should simplify your mathematics a lot.
You can see the technique of using a separate destination image from any -verbose output for the 'plus' +distort.
It also should simplify your mathematics a lot.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with composite images
I am not using distort. I am using composite displace. And I am also not always using fx either. So I am not sure what you are suggesting?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Help with composite images
I mean craete a destination image that is the right size, and make it the first image, and have -fx read the color from the source image given as the second or 'v' image.fmw42 wrote:I am not using distort. I am using composite displace. And I am also not always using fx either. So I am not sure what you are suggesting?
See the FX Equivelent output for ANY -verbose +distort operattion for an FX example.
EG:
Code: Select all
convert rose: -matte -virtual-pixel transparent -verbose \
+distort Perspective "0,0,0,0 0,46,0,46 70,0,60,10 70,46,60,30" \
+verbose null:
Code: Select all
-size 62x48 -page -1-1 xc: +insert \
-fx 'ii=i+page.x+0.5; jj=j+page.y+0.5;
rr=-0.009420*ii -0.000000*jj + 1;
xx=(+0.507246*ii +0.000000*jj -0.000000)/rr;
yy=(-0.166667*ii +1.000000*jj -0.000000)/rr;
rr>0 ? v.p{ xx-v.page.x-.5, yy-v.page.x-.5 } : blue'
the source image and colors looked up using the fx operation v.p{...}
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with composite images
I believe I understand what you are asking me to do (as I have done that before with -fx), but I don't use -distort anywhere and not always -fx to create the distortion maps nor to apply the distortion map. Applying the distortion maps is done with composite displace and not -distort. Anyway, the resizing is easy with -scale to convert from a 1 row image to one of the desired padded height. The only addition is to trim the result, but only as an option. I am allowing it to be trimmed in 1 dimension, 2 dimension or not at all. I may even be able to generate the exact height without padding and trimming, but I have not yet worked on that. I have some other things also still to change and test.
If I misunderstand, please clarify as I am confused about how to use a second image when I am not using -fx (or -distort).
If I misunderstand, please clarify as I am confused about how to use a second image when I am not using -fx (or -distort).
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Help with composite images
I did not ask you to use -distort in your scripts, only examine its equivalence output to get across the idea of distorting directly to an image that is already the right size.fmw42 wrote:I believe I understand what you are asking me to do (as I have done that before with -fx), but I don't use -distort anywhere and not always -fx to create the distortion maps nor to apply the distortion map. Applying the distortion maps is done with composite displace and not -distort. Anyway, the resizing is easy with -scale to convert from a 1 row image to one of the desired padded height. The only addition is to trim the result, but only as an option. I am allowing it to be trimmed in 1 dimension, 2 dimension or not at all. I may even be able to generate the exact height without padding and trimming, but I have not yet worked on that. I have some other things also still to change and test.
If I misunderstand, please clarify as I am confused about how to use a second image when I am not using -fx (or -distort).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with composite images
I can certainly use the less efficient fx everywhere to make the distortion maps the correct size, but then they will not match in source image. How does composite displace handle that? I do not want to replace composite displace with fx. The whole point of the exercise was to speed up what I can do easily with fx by using composite displace.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Help with composite images
Composite displace can not handle a image size change ;-(
If I every get around to creating a replacement displace operator (with optional EWA handling compressed areas) then yes size changes (or viewports) should be posible.
The better solution would of course be to get cylindrical distortions built into the -distort operator, and allow its use of +distort, and handling of invalid pixels (-matte color).
If I every get around to creating a replacement displace operator (with optional EWA handling compressed areas) then yes size changes (or viewports) should be posible.
The better solution would of course be to get cylindrical distortions built into the -distort operator, and allow its use of +distort, and handling of invalid pixels (-matte color).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with composite images
OK. Now we are on the same page. In the mean time, I am still working to streamline my script and make modifications.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with composite images
My script, cylinderize, is now done and uploaded to my server at http://www.fmwconcepts.com/imagemagick/index.html
It has been updated to permit tilting of the cylinder.
It has been updated to permit tilting of the cylinder.