Revision 464e53fa
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/library/EffectQueuePostprocess.java | ||
---|---|---|
93 | 93 |
// Support blurs consisting of the present pixel and up to MAX_BLUR pixels in each direction |
94 | 94 |
private static final int MAX_BLUR = 50; |
95 | 95 |
|
96 |
// The (linearly-sampled) Gaussian Blur kernels are of the size k0=1, k1=2, k2=2, k3=3, k4=3, k5=4, k6=4,...
|
|
96 |
// The (fixed-function-sampled) Gaussian Blur kernels are of the size k0=1, k1=2, k2=2, k3=3, k4=3, k5=4, k6=4,...
|
|
97 | 97 |
// i.e. k(i)=floor((i+3)/2). (the 'i' in k(i) means 'blur taking into account the present pixel and 'i' pixels |
98 | 98 |
// in all 4 directions) |
99 | 99 |
// We need room for MAX_BLUR of them, and sum(i=0...N, floor((i+3)/2)) = N + floor(N*N/4) |
... | ... | |
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
181 |
// This implements the 'Better separable implementation using GPU fixed function sampling' from |
|
182 |
// https://software.intel.com/en-us/blogs/2014/07/15/an-investigation-of-fast-real-time-gpu-based-image-blur-algorithms |
|
181 | 183 |
|
182 | 184 |
private void computeGaussianKernel(int radius) |
183 | 185 |
{ |
... | ... | |
202 | 204 |
|
203 | 205 |
for(int i=0; i<=radius; i++) mWeights[i] /= sum; |
204 | 206 |
|
205 |
// squash the weights and offsets for linear sampling |
|
206 | 207 |
int numloops = radius/2; |
207 |
|
|
208 | 208 |
weightsCache[offset] = mWeights[0]; |
209 | 209 |
offsetsCache[offset] = 0.0f; |
210 | 210 |
|
... | ... | |
221 | 221 |
offsetsCache[index]=mOffsets[radius]; |
222 | 222 |
weightsCache[index]=mWeights[radius]; |
223 | 223 |
} |
224 |
|
|
225 |
|
|
226 |
android.util.Log.e("post", "computed kernel size "+radius+" put it into cache="+offset); |
|
227 | 224 |
} |
228 | 225 |
} |
229 | 226 |
|
Also available in: Unified diff
Beginnings of the 'Multiblur' app.