Adaptive sharpen slow - any way to speed up?

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
ulrichlang
Posts: 3
Joined: 2019-10-17T10:14:20-07:00
Authentication code: 1152

Adaptive sharpen slow - any way to speed up?

Post by ulrichlang »

Hi!

I'm using convert to do adaptive sharpen (usually with 0x1) and it is really slow. Does anyone know how to speed it up?

Thank you for anyone willing to help out!

Best
Ulrich
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Adaptive sharpen slow - any way to speed up?

Post by fmw42 »

What is your Imagemagick version, Q level and platform? How big is your image? Do you have enough RAM for the process?
ulrichlang
Posts: 3
Joined: 2019-10-17T10:14:20-07:00
Authentication code: 1152

Re: Adaptive sharpen slow - any way to speed up?

Post by ulrichlang »

Thanks for getting back to me.
Ubuntu 18.04.3 LTS

when I run "convert -version" I get:
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib


The image is 730KB, 5760x3589 - here is a temporary link to the image: https://objectsecurity.com/tmp/tmpimg.jpg

I don't know the Q level - how can I find that out?

Thanks!
Ulrich
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Adaptive sharpen slow - any way to speed up?

Post by fmw42 »

You are using Q16 as per your listed information. However, the date of your version is 20170114, which is 2.5 years old (01/14/2017). You should see if there is an upgrade or patch to a current date.

How many cores does your computer have. More cores means faster processing, generally. However, on some systems, disabling OpenMP can make it run faster for certain operations. But this is rare.

For large (dimensions) images, see https://imagemagick.org/Usage/files/#massive.

Adjusting your policy.xml file may also provide some benefit for large images.

Recompiling to Q8 may also help by using less RAM.

Otherwise, I am not sure how you can improve speed with Imagemagick. If your speed is unacceptable, then perhaps look into the VIPS image processing tool.

You have never said what the speed is?

If I have computed correctly, your size image for 3 channels would be 5420520 bytes = 5.4 GB for the input and likewise for the output. Do you have about 11 GB RAM available? Adjusting the policy.xml file may help. But if you are on a shared server, your host may not be willing to change it. See https://imagemagick.org/script/resources.php for the policy.xml adjustments. Sorry, I am not an expert on these -limit arguments.

See

Code: Select all

convert -list resource
to get your current limits.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Adaptive sharpen slow - any way to speed up?

Post by snibgo »

At 8 bytes/pixel, each copy of the 5760x3589 image needs 0.165 GB. Adaptive sharpen needs two more copies, so we need 0.5 GB.

@ulrichlang: What is your command, and how long does it take? Eg "magick tmpimg.jpg -adaptive-sharpen 5x1 NULL:" on my 2.4GHz laptop takes 22 seconds.

Check that no temporary files are created during the command. If they are, you have run out of memory.

Check that "-limit thread 1" increases the time required. If it does, then multi-threading is useful for you.

If you have run out of memory, then try it with no other progams running (eg web browsers). If that doesn't cure the problem, insert "-list resource" to check there are no unwanted limits. Also try with Q8 to halve the memory usage.
snibgo's IM pages: im.snibgo.com
ulrichlang
Posts: 3
Joined: 2019-10-17T10:14:20-07:00
Authentication code: 1152

Re: Adaptive sharpen slow - any way to speed up?

Post by ulrichlang »

Hi! Thanks!!! wow, yes there were some really low resource limits set. I didn't know those were set so low. I am runnning this in a high-cpu cloud instance and now that processes the image in 18 seconds (vs. 2-4 minutes before). Thanks again!

(PS the low limits are default set up when installing "out of the box" on ubuntu)
Post Reply