Shepards distort performance improvement?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tresorjoe
Posts: 13
Joined: 2018-04-12T02:19:12-07:00
Authentication code: 1152

Shepards distort performance improvement?

Post by tresorjoe »

Hello,

I am facing performance issues on large RGB files (example 20000px by 12000px). The Shepards distort takes >30 minutes to process such kind of files. I have tried with TIF format (with and without LZW compression) as well as PSD file format. Also tried Q8 version of ImageMagick but the improvement is minimal. Working on a virtual Windows 10 (2017 Macbook Pro fully powered, running Parallels Desktop with 2GB RAM, 2 CPUs). Might that be too low?

Are there any tricks to drastically improve the performance? The final intention is to run files with approx. 60000px by 30000px in under a minute with "standard" hardware.

PS: I have tried to run it natively on Mac, here are the results:
TIF (no LZW): 1:54.809
TIF (LZW): 1:55.719
PSD: 1:50.549

Thanks,
Joe
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Shepards distort performance improvement?

Post by snibgo »

You have large images (20000px by 12000px is 240 megapixels, which needs about 2 GB memory) on a machine with only 2 GB memory? Then IM will store the pixe cache on disk, which is very slow. I suggest you use a machine with more memory.

How many control points are in the Shepards distortion? Every output pixel depends on every control point, so reducing that number will improve performance.
snibgo's IM pages: im.snibgo.com
tresorjoe
Posts: 13
Joined: 2018-04-12T02:19:12-07:00
Authentication code: 1152

Re: Shepards distort performance improvement?

Post by tresorjoe »

That makes sense, thanks for the info.
There are 7 control points in Shepards distortion, where the 4 corner points are fixed (input = output) and 3 points are moved (left-center, center-center, right-center). I think I need all of these 7 points to obtain the distortion that I need. Further ideas?
Thanks again
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Shepards distort performance improvement?

Post by snibgo »

Here's a simple test, with just two control points:

Code: Select all

magick -size 20000x12000 xc: -distort Shepards "0,0,0,0 19999,0,19999,0" NULL:
On my 12 GB Windows 8.1 laptop, this uses disk for pixel caches (2 files each 2.8 GB), and takes 3 minutes. (So 7 control points would need 10.5 minutes on my computer.)

Halving the width doesn't use the disk, and takes 20 seconds. (So 7 control points would need 70 seconds.)

Based on this, I'm fairly sure you don't have enough memory, and that increasing this will solve your performance problem.
snibgo's IM pages: im.snibgo.com
Post Reply