问题
I'm using Brad Larson's GPUImage framework. However when I'm trying to apply kuwahara
filter with filter radius 5.0f
, I'm getting artifacts on an iPhone 4S. (works fine on higher performance devices)
Source image size was 2048x2048px.
By reading original developer's comments I understood that there's a kind of watchdog timer which fires when something takes too long to run on the GPU.
So my question is , what is the maximum possible resolution for an iPhone 4S I can apply Kuwahara
filter with radius of 5.0f
without getting artifacts ?
回答1:
There really isn't a hard limit. The tiling artifacts you are seeing are due to the OpenGL ES watchdog timer aborting the scene rendering after it takes too long. If you have a single frame that takes longer than approximately 2 seconds to render, your frame rendering will be killed in this manner.
The exact time it takes is a function of hardware capabilities, system load, shader complexity, and iOS version. In GPUImage, you pretty much only see this with the Kuwahara filter because of the ridiculously unoptimized shader I use for that. It's drawn from a publication that was doing this using desktop GPUs, and is about the worst case operation for a mobile GPU like these. Someone contributed a fixed-radius version of this which is significantly faster, but you'll need to create your own optimized version if you want to use this with large images on anything but the latest devices.
回答2:
Kuwahara filter makes square artefacts and very complex.
- You can use Generalised Kuwahara filter (e.g. with 8 segments).
- You can manually generate shader without cycles for selected radius. For decreased number of readings from texture, you can make trick:
- Generate shader for constant radius.
- Pixels offset must depend on ratio of current radius and constant radius.
You get some artefacts, but they are artistic (like canvas). And Kuwahara will be faster.
来源:https://stackoverflow.com/questions/24654047/gpuimage-kuwahara-filter-on-iphone-4s