core image

QC and very large images

psonice's picture

Any suggestions for keeping QC efficient when working with large images?

I've got a little side-project (asteroid hunting of all things!) that involves processing a big bunch of large (as in DSLR size) images in 32bit mode. I've worked out the memory requirements for this at around 128mb per image.. ouch.

Well, QC seems to handle tiling the images transparently in the background, and with only one image plus a few copies loaded at any one time, it should run a little slow but otherwise OK right? Well, no.. in fact when I ran my composition it ate 6GB of ram. 6GB! I only have 4GB in total, my poor mac was nearly killed :D The composition isn't that heavy though, it should use a couple of GB or so.

First question then: how the hell do I keep memory usage to a minimum?

One possible issue is that I'm doing feedback rendering. Using CI with feedback is well known for causing a memory leak (I REALLY fear the results of that leak in this case :D) but I've re-worked my feedback using GLSL to get around it. I don't see any leakage with smaller images, and this seems to be stable once it's used a big chunk of memory.

Another problem is that the GPU's maximum texture size seems to be 1k x 1k for 32 bit mode (same memory footprint as the normal 4k x 4k in 8 bit mode). Again, QC seems to manage it seamlessly in the background, but I get issues with CI filters around the tile edges if I try to sample outside the current tile... any fix for that?

For now, I've created a macro that splits the image into 1024x1024 chunks so I can process them one at a time and recombine at the end. Not ideal, but it should get me running at least.. I'll have to add some overlap to the tiles if I can't figure out the CI issue. It's still going to eat too much memory though, so any advice is much needed :)

GL Tools 1.4 crash in Music Visualizer

cybero's picture

Please find quoted below the resulting crash report when iTunes ducked my CLGL variation of the Arabesque screensaver as a music visualier. I am going to dive in and take a look at what I've changed to provoke this error, seems to be one of the presets alone, all others run AOK.

GLTools got mentioned in dispatches as follows :-

Process:         iTunes [1936]
Path:            /Applications/iTunes.app/Contents/MacOS/iTunes
Identifier:      com.apple.iTunes
Version:         9.0.3 (9.0.3)
Build Info:      iTunes-9031501~5
Code Type:       X86 (Native)
Parent Process:  launchd [134]
 
PlugIn Path:       /Users/cybero/Library/Graphics/Quartz Composer Patches/GLTools.plugin/Contents/MacOS/GLTools
PlugIn Identifier: net.kineme.GLTools
PlugIn Version:    1.4 (20091217.2212r6563)
 
Date/Time:       2010-02-24 12:41:20.288 +0000
OS Version:      Mac OS X 10.6.2 (10C540)
Report Version:  6
 
Interval Since Last Report:          321683 sec
Crashes Since Last Report:           58
Per-App Interval Since Last Report:  190820 sec
Per-App Crashes Since Last Report:   1
Anonymous UUID:                      1AA3AE71-8AF0-44AD-8109-9157EDB0AF38
 
Exception Type:  EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Crashed Thread:  0  Dispatch queue: com.apple.main-thread
 
Application Specific Information:
objc[1936]: FREED(id): message retain sent to freed object=0x1de4bc30
 
Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                  0x970374b4 _objc_error + 116
1   libobjc.A.dylib                  0x970374ea __objc_error + 52
2   libobjc.A.dylib                  0x970357dc _freedHandler + 58
3   com.apple.QuartzComposer         0x968d0b48 -[QCStreamExporter_QCArray createRepresentationOfType:withProvider:withCount:elementSize:type:options:] + 1830
4   com.apple.QuartzComposer         0x968d0178 -[QCStreamManager createRepresentationFromProvider:ofType:withCount:elementSize:type:options:] + 1490
5   com.apple.QuartzComposer         0x969c7ce0 -[QCStream(QCStructure) _populateWithStream] + 301
6   com.apple.QuartzComposer         0x969c737e -[QCStream(QCStructure) memberAtIndex:] + 71
7   net.kineme.GLTools               0x1e296ebf 0x1e27c000 + 110271
8   com.apple.QuartzComposer         0x96840575 -[QCRenderingManager renderAtTime:arguments:] + 1674
9   com.apple.QuartzComposer         0x968a5a71 -[QCRenderInImage executeSubpatches:arguments:] + 118
10  com.apple.QuartzComposer         0x968a54cc -[QCRenderInImage execute:time:arguments:] + 2557
11  com.apple.QuartzComposer         0x9683f396 -[QCPatch(Private) _renderAtTime:arguments:] + 111
12  com.apple.QuartzComposer         0x9683f302 -[QCRenderingManager addPatch:context:time:arguments:nextExecutionTime:] + 2200
13  com.apple.QuartzComposer         0x9683e21f -[QCPatch(Private) __execute:arguments:] + 754
14  com.apple.QuartzComposer         0x9683deba -[QCPatch(Private) _execute:arguments:] + 1728
15  com.apple.QuartzComposer         0x9683e991 -[QCPort _execute:arguments:] + 268
16  com.apple.QuartzComposer         0x9683dd6e -[QCPatch(Private) _execute:arguments:] + 1396
17  com.apple.QuartzComposer         0x9683e991 -[QCPort _execute:arguments:] + 268
18  com.apple.QuartzComposer         0x9683dd6e -[QCPatch(Private) _execute:arguments:] + 1396
19  com.apple.QuartzComposer         0x9683e991 -[QCPort _execute:arguments:] + 268
20  com.apple.QuartzComposer         0x9685dc3d -[QCMultiplexerImagePort _execute:arguments:] + 130
21  com.apple.QuartzComposer         0x9683dd6e -[QCPatch(Private) _execute:arguments:] + 1396
22  com.apple.QuartzComposer         0x9683e991 -[QCPort _execute:arguments:] + 268
23  com.apple.QuartzComposer         0x9683dd6e -[QCPatch(Private) _execute:arguments:] + 1396
24  com.apple.QuartzComposer         0x9683e7ac -[QCPatch(Private) _executeSubpatches:arguments:] + 243
25  com.apple.QuartzComposer         0x9683e5e1 -[QCPatch(Customization) nextExecutionTimeForSubpatches:time:arguments:] + 192
26  com.apple.QuartzComposer         0x9683e4e9 -[QCPatch(Customization) nextExecutionTime:time:arguments:] + 81
27  com.apple.QuartzComposer         0x9683e443 -[QCPatch(Private) _nextExecutionTime:arguments:] + 461
28  com.apple.QuartzComposer         0x9683e18f -[QCPatch(Private) __execute:arguments:] + 610
29  com.apple.QuartzComposer         0x9683deba -[QCPatch(Private) _execute:arguments:] + 1728
30  com.apple.QuartzComposer         0x9683e7ac -[QCPatch(Private) _executeSubpatches:arguments:] + 243
31  com.apple.QuartzComposer         0x9683e5e1 -[QCPatch(Customization) nextExecutionTimeForSubpatches:time:arguments:] + 192
32  com.apple.QuartzComposer         0x9683e4e9 -[QCPatch(Customization) nextExecutionTime:time:arguments:] + 81
33  com.apple.QuartzComposer         0x9683e443 -[QCPatch(Private) _nextExecutionTime:arguments:] + 461
34  com.apple.QuartzComposer         0x9683e1d7 -[QCPatch(Private) __execute:arguments:] + 682
35  com.apple.QuartzComposer         0x9683deba -[QCPatch(Private) _execute:arguments:] + 1728
36  com.apple.QuartzComposer         0x9683c4ba -[QCContext nextExecutionTimeForPatch:time:arguments:] + 643
37  com.apple.QuartzComposer         0x9683c231 -[QCGraphicsContext nextExecutionTimeForPatch:time:arguments:] + 73
38  com.apple.QuartzComposer         0x9683c00b -[QCOpenGLContext nextExecutionTimeForPatch:time:arguments:] + 528
39  com.apple.QuartzComposer         0x9683bde8 -[QCPatch(Runtime) nextExecutionTime:arguments:] + 92
40  ...QuartzComposer.iTunesPlugIn   0x188ead89 iTunesPluginMainMachO + 9304
41  ...QuartzComposer.iTunesPlugIn   0x188eb210 iTunesPluginMainMachO + 10463

I will try to reproduce the CLGL related problem in a simpler composition that does not redistribute Apple's own code, as is personally and privately the case on my machine at present.

First sigill of this year BTW :-) .

Drop Alpha Channel (Composition by smokris)

Author: smokris
License: MIT
Date: 2010.02.07
Compatibility: 10.5, 10.6
Categories:
Required plugins:
(none)

Removes the alpha channel from an image (i.e., makes it fully opaque).

Image Rehab (Composition by smokris)

Author: smokris
License: MIT
Date: 2010.02.07
Compatibility: 10.5, 10.6
Categories:
Required plugins:
(none)

Core Image is incredibly powerful, but sometimes produces images with non-obvious properties. Image Rehab attempts to clean up some of these properties.

  • Image Origin is restored to (0,0) — potentially useful after cropping an image.
  • Unbounded Images are trimmed to the dimensions of the Rendering Destination.

Low / high pass filters

sbn..'s picture

Hello all,

For a composition I'm doing, I need something akin to a clamp or high pass filter. What I mean is a patch that'll accept an image and a color input, and then output a pure black / pure white image using the color as a threshold.

For my application, this would be used with an image that's already b/w, so it could use e.g. only the red channel.

I've tried my hand at a Core Image filter that does this, but I'm utterly bewildered since the documentation is so scant. I keep getting errors about data-dependent conditionals and swizzles.

Is it really impossible to return a value from a CI filter based on a conditional statement?

Or is there an obvious way of doing this I'm missing? In other software, I'd use a curve adjustment or similar, but I haven't found an equivalent in QC. The color controls is too fidgety and dependent on the input image.

Any pointers would be appreciated.