Re: Gaussian blur with core image, using CPU or GPU?
Re: Gaussian blur with core image, using CPU or GPU?
- Subject: Re: Gaussian blur with core image, using CPU or GPU?
- From: Johannes Fortmann <email@hidden>
- Date: Fri, 23 May 2008 21:01:05 +0200
Hi everyone,
I'm trying to write a bilateral filter using Core Image with the
specific goal of having it preform the filter on the GPU for high
performance as this will be for large 4d data sets.
I started out by reading the Core Image Programming Guide and came to
the "Writing Nonexecutable Filters" page and came across this
sentence:
"Core Image assumes that the ROI coincides with the domain of
definition. This means that nonexecutable filters are not suited for
such effects as blur or distortion."
Does this mean that it is not possible to write a bilateral filter
which does the computations on the GPU?
I've looked at the Core Image gaussian filter. Thus far I cannot find
out whether it is executed on the CPU or GPU and I was wondering if
there is a way to determine this. Is there source code available for
this filter and if so where is it? I have had no luck finding it so
far.
Hope this works; I'm not subscribed to the list (prefer to read via
the archives), but none of the answers you got looked very conductive
to your problem.
A filter being nonexecutable means there's no machine-dependent code
in the filter's bundle. A nonexecutable filter only contains resource
files (usually filter kernels and a description plist).
From a filter kernel, it's not easily possible to infer the ROI, that
is, the source image area that the filter depends on. For simple
filters (like the color manipulation ones) that's not a problem: every
source pixel only influences exactly the corresponding destination
pixel. For a other filters there's a set of source pixels influencing
each destination pixel (e.g. for a blur filter of kernel size r, every
source pixel that's less than r away from the primitive source pixel
will influence the result). Of course, for a blur kernel that's
simple, but for some filters computing the ROI isn't that easy.
Accordingly, you'd subclass CIFilter, implement a ROI selector and set
it on your kernels. The kernels will still be executed on the graphics
card. The CIDemoImageUnit example does this in FunHouseMirrorFilter.m;
look for the regionOf: method.
The reason for the distinction between executable and non-executable
filters is that some people might not want to load foreign code into
their address space (just like they might not like to load input
managers).
BTW, it's highly unlikely that the built-in gaussian filter does any
magic; they likely use the radius property to build a filter that
calls sample() r*r times, adds the values up with gaussian weights,
and returns the result.
Cheers,
Johannes
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden