Problem with memor allocation (i suppose)

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
Gogolian
Posts: 1
Joined: 2015-05-28T06:20:41-07:00
Authentication code: 6789

Problem with memor allocation (i suppose)

Post by Gogolian »

Hello,

This is my first post here so please be gentle

I already tried searching for solutions and decided that i will most probably need some help.

I would like to do the fast fourier transform on very large image 24288x14968.

Currently i am on windows at work.

I have a downloaded version of imagemagic with fft transform.

I first tried on the clown.jpg test file to check if it works and it did, both ways, with successfully clearing out unwanted patterns.

My code for this was:

Code: Select all

.\convert -monitor Zdjecie1.png -fft ( +clone -write clown_phase.png +delete ) +delete -write clown_magnitude.png -colorspace gray -auto-level -evaluate log 100000 clown_spectrum.png
then making a mask (i am making it by hand)

and then the inverse:

Code: Select all

.\convert -monitor clown_magnitude.png clown_spectrum_mask.png -compose multiply -composite clown_phase.png -ift clown_filtered.png
Now i switched to my big picture.

It loads the file, starts making 'clown_phase.png' file, you can see it inflating to 258466 Kb (Original file filesize is 1 065 263Kb), and then crashed:

Code: Select all

convert.exe: Memory allocation failed `Zdjecie1.png' @ error/fourier.c/ForwardFo
urierTransformChannel/597.
I tried tweaking limits different ways, the last one is like this:

Code: Select all

.\convert -limit area 128MB -limit disk 50GB -limit map 512MB -monitor Zdjecie1.png -monitor -fft -monitor ( +clone -write clown_phase.png +delete ) +delete -write clown_magnitude.png -colorspace gray -auto-level -evaluate log 100000 clown_spectrum.png
but no luck, it inflates the file every time to the same size.

I'm out of ideas, besides the one that when i go home i can install ubuntu or mint and try compiling IM from source and then try to run it there.

I am afraid that it won't make any difference though.

Is there any limit on fourier transform at all?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with memor allocation (i suppose)

Post by fmw42 »

I know of no size limitation of FFTW and have seen references to image sizes up to 2^31. I suspect that your -limits may be off and you are exceeding memory allocation. But one of the IM developers will likely need to comment.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Problem with memor allocation (i suppose)

Post by magick »

Make sure you have a modern version of ImageMagick, it forces the FFTW allocation to disk rather than memory for large resource requests. Your limits should be '-limit memory 2MB'. By making the memory limits small, it forces the allocation to memory mapped disk. Thus you don't want to limit the memory map limit. With memory-mapped backed disk, it will run slower than if the allocation is directly in memory but it should complete.
Post Reply