Page 2 of 2
Re: Tilt Shift
Posted: 2013-07-01T14:39:55-07:00
by gritter
fmw42 wrote:Did you see my comment above that if you use -compose blur and set one dimension to 0, it runs very quickly. I showed a result.
Most of your pictures did not show up. So I am not sure what you did in PS. Nevertheless, as above, you can achieve a similar result in a timely manner with -compose blur
Yes, I did see your previous example and I have just tested it (sorry for the delay). On my machine it took ~12 seconds, which is a damn sight faster than what I have been using, and the quality is acceptable.
I should point out that, while this machine isn't the fastest, the machine the command will ultimately be running on is a lot faster, but then it will be processing a lot more images, so the improvement in speed is important.
I'm sorry the pictures didn't show up, I wonder if other people can see them or if there is a problem with the image host I am using. Just for reference I will describe the steps for photoshop:
1) Open the source image and the mask image.
2) With the mask image visible use ctrl-a to marquee the entire image, then use ctrl-c. (or command-a etc...) to copy to the clipboard.
3) Switch to the source image and open the channels palette.
4) Create a new channel.
5) Select the new channel and use ctrl-v to paste the mask into it.
6) Hold ctrl and click the thumbnail for the new channel to produce a selection based on the mask.
7) Click the RGB channel to show the source image.
Go to Filters > Blur > Lens blur and apply a blur of, say, 50 pixels.
9) ctrl-d to clear the selection.
10) Done.
Re: Tilt Shift
Posted: 2013-07-01T15:14:50-07:00
by fmw42
Thanks. I was trying to work with the layers mask, but could not get it to work. It does work when you put the mask into an alpha channel.
Lens blur is different from gaussian blur (as per IM copy blur), so the results will be some different.
Re: Tilt Shift
Posted: 2013-07-01T20:09:05-07:00
by anthony
fmw42 wrote:Did you see my comment above that if you use -compose blur and set one dimension to 0, it runs very quickly. I showed a result.
While that image (horizontal only blur) is not right. I wonder if you can do this as a two pass variable blur.
Do it once with one value 0, then do it again with the other value 0. May not be as exact but it may be faster!
Re: Tilt Shift
Posted: 2013-07-02T20:39:31-07:00
by fmw42
Anthony wrote:Do it once with one value 0, then do it again with the other value 0. May not be as exact but it may be faster!
Yes that does work rather faster than the 2D blur.
convert street.jpg mask.png -compose Blur -set option:compose:args 25x0 -composite \
mask.png -compose Blur -set option:compose:args 0x25 -composite street_comp_blur25x2.jpg
Re: Tilt Shift
Posted: 2013-07-02T21:41:50-07:00
by snibgo
Yup, that's quicker. On a 7360x4912 image, using a gradient mask, blur 11x11 took 23 mins 50 secs, where blur 11x0 followed by blur 0x11 took 5 mins 15 secs. Visually identical. Thanks.
Re: Tilt Shift
Posted: 2013-07-02T22:21:09-07:00
by anthony
Example of a two pass tilt-shift added to IM examples
http://www.imagemagick.org/Usage/photos/#tilt_shift
as always give it a few hours for the new 'speed optimization' to appear.
convert beijing_md.jpg -sigmoidal-contrast 15x30% \
\( +clone -sparse-color Barycentric '0,0 black 0,%h gray80' \
-solarize 50% -level 50%,0 -write mpr:blur_map \) \
-compose Blur -set option:compose:args 5x0 -composite \
mpr:blur_map \
-compose Blur -set option:compose:args 0x5 -composite \
beijing_model_2pass.jpg
I am certain a 'clone' method can be used instead of saving the mapping image using a MPR: register, But it works.
It is not as 'exact', and I believe doing a vertical blur before a horizontal may be more exact. as it is the horizontal that is constant along the direction of the blur (so do it last). I have not tried though.
Re: Tilt Shift
Posted: 2013-07-03T16:54:21-07:00
by fmw42
Anthony wrote:It is not as 'exact', and I believe doing a vertical blur before a horizontal may be more exact. as it is the horizontal that is constant along the direction of the blur (so do it last). I have not tried though.
horizontal then vertical
convert street.jpg mask.png -compose Blur -set option:compose:args 25x0 -composite mask.png -compose Blur -set option:compose:args 0x25 -composite street_comp_blur25x2.jpg
vertical then horizontal
convert street.jpg mask.png -compose Blur -set option:compose:args 0x25 -composite mask.png -compose Blur -set option:compose:args 25x0 -composite street_comp_blur25x2b.jpg
compare -metric rmse street_comp_blur25x2.jpg street_comp_blur25x2b.jpg null:
188.508 (0.00287644)
Very slight difference visually (at the corner of the dark roof overhang) with the second slightly better in my opinion than the first.
Re: Tilt Shift
Posted: 2013-07-15T10:08:03-07:00
by gritter
I apologise for not posting for a while, IRL stuff came up etc.
I also appreciate everyone's input in this thread, it was very helpful having all the different ideas. But for my purposes the solutions offered are just too slow so I will have to shelf the project until I can find a solution.
Re: Tilt Shift
Posted: 2013-07-15T10:41:30-07:00
by fmw42
Is it too slow even use the two pass vertical then horizontal -compose blur?
Re: Tilt Shift
Posted: 2013-08-02T09:55:09-07:00
by gritter
Again, I apologise for the delay.
fmw42 wrote:Is it too slow even use the two pass vertical then horizontal -compose blur?
I tested the 2-pass technique and it took ~7 seconds on the street image, which is a huge improvement in speed. I will have to test it on some real images to determine whether it is fast enough, but I regretfully suspect that it won't be enough.
Re: Tilt Shift
Posted: 2013-08-02T10:40:04-07:00
by fmw42
Do you have a multi-core processor and OpenMP enabled?
Re: Tilt Shift
Posted: 2013-08-02T13:18:03-07:00
by gritter
fmw42 wrote:Do you have a multi-core processor and OpenMP enabled?
Yes (2 cores on this box), and I am guessing no, since my CPU monitor only goes up to 50%.
It's not particularly important though, since I was hoping to run several instances in parallel.
Re: Tilt Shift
Posted: 2013-08-02T17:52:16-07:00
by fmw42
OpenMP allows processing speed up by utilizing more than one core. It is not like OpenCL for display hardware speedup for which there are only a few current IM functions that will utilize OpenCL.
If
convert -version
lists OpenMP then it is enabled and using your two cores as best it can.