import config, wavelets/wptree, wavelets/daubechies_d4, wavelets/haar

int def test_randwp(char const *filename, char const *what):
    Wavelet *wavelet = ALLOCATE0(sizeof *wavelet)
    wavelet->transform = daubechies_d4_transform_no_key
    #wavelet->transform = haar_transform_no_key
    int key = time(NULL)
    int min_ll_depth = 5
    int max_ll_depth = 5
    int max_depth = 5
    double base_value = 1
    double change_factor = 0
    bool is_1d = False

    mersenne_seed(key)
    WPNode *tree = wptree_create_random_tree(wavelet, 512, 64,
        min_ll_depth, max_ll_depth, max_depth,
        base_value, change_factor, is_1d)

    Image *image = image_load_b(filename)
    Image *v = BtoV(image)
    shift_multiply_image(v, -127.5, 1)
    Image *result = wptree_transform(tree, v)

    char name[1024]
    get_image_name(image, "wp", name)

    Image *r2 = image_copy(result)
    shift_multiply_image(r2, 127.5, 1)
    Image *b = VtoB(r2)
    save_tiff_luminance(name, b)

    wptree_plot(tree, "test.eps")

    return 0
