mirror of
				https://github.com/stevenrobertson/cuburn.git
				synced 2025-11-03 18:00:55 -05:00 
			
		
		
		
	Expose options on filter
This commit is contained in:
		@ -1,4 +1,3 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
import numpy as np
 | 
					import numpy as np
 | 
				
			||||||
from numpy import float32 as f32, int32 as i32
 | 
					from numpy import float32 as f32, int32 as i32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -175,6 +174,9 @@ __global__ void blur_v(float *dst) {
 | 
				
			|||||||
/* sstd:    spatial standard deviation (Gaussian filter)
 | 
					/* sstd:    spatial standard deviation (Gaussian filter)
 | 
				
			||||||
 * cstd:    color standard deviation (Gaussian on the range [0, 1], where 1
 | 
					 * cstd:    color standard deviation (Gaussian on the range [0, 1], where 1
 | 
				
			||||||
 *          represents an "opposite" color).
 | 
					 *          represents an "opposite" color).
 | 
				
			||||||
 | 
					 * angstd:  inverse standard deviation of negative of cosine of angle
 | 
				
			||||||
 | 
					 *          between current filter direction and density gradient direction
 | 
				
			||||||
 | 
					 *          (yes, this is absurd; no, I'm not joking)
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Density is controlled by a power-of-two Gompertz distribution:
 | 
					 * Density is controlled by a power-of-two Gompertz distribution:
 | 
				
			||||||
 *  v = 1 - 2^(-sum^dpow * 2^((dhalfpt - x) * dspeed))
 | 
					 *  v = 1 - 2^(-sum^dpow * 2^((dhalfpt - x) * dspeed))
 | 
				
			||||||
@ -192,13 +194,11 @@ __global__ void blur_v(float *dst) {
 | 
				
			|||||||
 *          cell.
 | 
					 *          cell.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
__global__
 | 
					__global__
 | 
				
			||||||
void bilateral(float4 *dst, float sstd, float cstd,
 | 
					void bilateral(float4 *dst, int r, float sstd, float cstd, float angscale,
 | 
				
			||||||
               float dhalfpt, float dspeed, float dpow) {
 | 
					               float dhalfpt, float dspeed, float dpow) {
 | 
				
			||||||
    int x = blockIdx.x * blockDim.x + threadIdx.x;
 | 
					    int x = blockIdx.x * blockDim.x + threadIdx.x;
 | 
				
			||||||
    int y = blockIdx.y * blockDim.y + threadIdx.y;
 | 
					    int y = blockIdx.y * blockDim.y + threadIdx.y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const int r = 7;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Precalculate the spatial coeffecients.
 | 
					    // Precalculate the spatial coeffecients.
 | 
				
			||||||
    __shared__ float spa_coefs[32];
 | 
					    __shared__ float spa_coefs[32];
 | 
				
			||||||
    if (threadIdx.y == 0) {
 | 
					    if (threadIdx.y == 0) {
 | 
				
			||||||
@ -260,8 +260,7 @@ void bilateral(float4 *dst, float sstd, float cstd,
 | 
				
			|||||||
            // Oh, this is ridiculous. But it works!
 | 
					            // Oh, this is ridiculous. But it works!
 | 
				
			||||||
            float factor = spa_coefs[abs(i)]  * spa_coefs[abs(j)]
 | 
					            float factor = spa_coefs[abs(i)]  * spa_coefs[abs(j)]
 | 
				
			||||||
                         * expf(cscale * cdiff) * dfact
 | 
					                         * expf(cscale * cdiff) * dfact
 | 
				
			||||||
                         * exp2f(2.0f * (-angfact - 1.0f));
 | 
					                         * exp2f(angscale * (-angfact - 1.0f));
 | 
				
			||||||
 | 
					 | 
				
			||||||
            weightsum += factor;
 | 
					            weightsum += factor;
 | 
				
			||||||
            out.x += factor * pix.x;
 | 
					            out.x += factor * pix.x;
 | 
				
			||||||
            out.y += factor * pix.y;
 | 
					            out.y += factor * pix.y;
 | 
				
			||||||
@ -328,7 +327,7 @@ class Filtering(HunkOCode):
 | 
				
			|||||||
        bilateral, blur_h, blur_h_1cp, blur_v, fma_buf = map(
 | 
					        bilateral, blur_h, blur_h_1cp, blur_v, fma_buf = map(
 | 
				
			||||||
                self.mod.get_function,
 | 
					                self.mod.get_function,
 | 
				
			||||||
                'bilateral blur_h blur_h_1cp blur_v fma_buf'.split())
 | 
					                'bilateral blur_h blur_h_1cp blur_v fma_buf'.split())
 | 
				
			||||||
        ROUNDS = 2 # TODO: user customizable?
 | 
					        ROUNDS = 1 # TODO: user customizable?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def do_bilateral(bsrc, bdst):
 | 
					        def do_bilateral(bsrc, bdst):
 | 
				
			||||||
            tref.set_address_2d(bsrc, dsc, sb)
 | 
					            tref.set_address_2d(bsrc, dsc, sb)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user