Skip to content

Commit 9df044e

Browse files
author
Joe Petviashvili
committed
add anisotropic_diffusion
1 parent b9a849c commit 9df044e

File tree

2 files changed

+61
-40
lines changed

2 files changed

+61
-40
lines changed

src/common.jl

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ export AF_BACKEND_CPU, AF_BACKEND_CUDA, AF_BACKEND_DEFAULT, AF_BACKEND_OPENCL, A
66
export AF_BINARY_MIN, AF_BINARY_MUL, AF_CANNY_THRESHOLD_AUTO_OTSU, AF_CANNY_THRESHOLD_MANUAL, AF_COLORMAP_BLUE
77
export AF_COLORMAP_COLORS, AF_COLORMAP_DEFAULT, AF_COLORMAP_HEAT, AF_COLORMAP_MOOD, AF_COLORMAP_RED, AF_COLORMAP_SPECTRUM
88
export AF_CONNECTIVITY_4, AF_CONNECTIVITY_8, AF_CONV_AUTO, AF_CONV_DEFAULT, AF_CONV_EXPAND, AF_CONV_FREQ
9-
export AF_CONV_SPATIAL, AF_ERR_ARG, AF_ERR_ARR_BKND_MISMATCH, AF_ERR_BATCH, AF_ERR_DEVICE, AF_ERR_DIFF_TYPE
10-
export AF_ERR_DRIVER, AF_ERR_INTERNAL, AF_ERR_INVALID_ARRAY, AF_ERR_LOAD_LIB, AF_ERR_LOAD_SYM, AF_ERR_NONFREE
11-
export AF_ERR_NOT_CONFIGURED, AF_ERR_NOT_SUPPORTED, AF_ERR_NO_DBL, AF_ERR_NO_GFX, AF_ERR_NO_MEM, AF_ERR_RUNTIME
12-
export AF_ERR_SIZE, AF_ERR_TYPE, AF_ERR_UNKNOWN, AF_FIF_BMP, AF_FIF_EXR, AF_FIF_HDR, AF_FIF_ICO, AF_FIF_JNG
13-
export AF_FIF_JP2, AF_FIF_JPEG, AF_FIF_PNG, AF_FIF_PPM, AF_FIF_PPMRAW, AF_FIF_PSD, AF_FIF_RAW, AF_FIF_TIFF
9+
export AF_CONV_SPATIAL, AF_DIFFUSION_DEFAULT, AF_DIFFUSION_GRAD, AF_DIFFUSION_MCDE, AF_ERR_ARG, AF_ERR_ARR_BKND_MISMATCH
10+
export AF_ERR_BATCH, AF_ERR_DEVICE, AF_ERR_DIFF_TYPE, AF_ERR_DRIVER, AF_ERR_INTERNAL, AF_ERR_INVALID_ARRAY
11+
export AF_ERR_LOAD_LIB, AF_ERR_LOAD_SYM, AF_ERR_NONFREE, AF_ERR_NOT_CONFIGURED, AF_ERR_NOT_SUPPORTED, AF_ERR_NO_DBL
12+
export AF_ERR_NO_GFX, AF_ERR_NO_MEM, AF_ERR_RUNTIME, AF_ERR_SIZE, AF_ERR_TYPE, AF_ERR_UNKNOWN, AF_FIF_BMP
13+
export AF_FIF_EXR, AF_FIF_HDR, AF_FIF_ICO, AF_FIF_JNG, AF_FIF_JP2, AF_FIF_JPEG, AF_FIF_PNG, AF_FIF_PPM
14+
export AF_FIF_PPMRAW, AF_FIF_PSD, AF_FIF_RAW, AF_FIF_TIFF, AF_FLUX_DEFAULT, AF_FLUX_EXPONENTIAL, AF_FLUX_QUADRATIC
1415
export AF_GRAY, AF_HOMOGRAPHY_LMEDS, AF_HOMOGRAPHY_RANSAC, AF_HSV, AF_ID, AF_INTERP_BICUBIC, AF_INTERP_BICUBIC_SPLINE
1516
export AF_INTERP_BILINEAR, AF_INTERP_BILINEAR_COSINE, AF_INTERP_CUBIC, AF_INTERP_CUBIC_SPLINE, AF_INTERP_LINEAR
1617
export AF_INTERP_LINEAR_COSINE, AF_INTERP_LOWER, AF_INTERP_NEAREST, AF_LSAD, AF_LSSD, AF_MARKER_CIRCLE
@@ -24,11 +25,11 @@ export AF_RANDOM_ENGINE_MERSENNE_GP11213, AF_RANDOM_ENGINE_PHILOX, AF_RANDOM_ENG
2425
export AF_RANDOM_ENGINE_THREEFRY_2X32_16, AF_RGB, AF_SAD, AF_SHD, AF_SSD, AF_STORAGE_COO, AF_STORAGE_CSC
2526
export AF_STORAGE_CSR, AF_STORAGE_DENSE, AF_SUCCESS, AF_YCC_2020, AF_YCC_601, AF_YCC_709, AF_YCbCr, AF_ZNCC
2627
export AF_ZSAD, AF_ZSSD, afDevice, afHost, af_array, af_backend, af_binary_op, af_border_type, af_canny_threshold
27-
export af_colormap, af_connectivity, af_conv_domain, af_conv_mode, af_cspace_t, af_dtype, af_err, af_features
28-
export af_homography_type, af_image_format, af_interp_type, af_marker_type, af_mat_prop, af_match_type
29-
export af_moment_type, af_norm_type, af_random_engine, af_random_engine_type, af_someenum_t, af_source
30-
export af_storage, af_window, af_ycc_std, b8, c32, c64, dim_t, f32, f64, intl, s16, s32, s64, u16, u32
31-
export u64, u8, uintl
28+
export af_colormap, af_connectivity, af_conv_domain, af_conv_mode, af_cspace_t, af_diffusion_eq, af_dtype
29+
export af_err, af_features, af_flux_function, af_homography_type, af_image_format, af_interp_type, af_marker_type
30+
export af_mat_prop, af_match_type, af_moment_type, af_norm_type, af_random_engine, af_random_engine_type
31+
export af_someenum_t, af_source, af_storage, af_window, af_ycc_std, b8, c32, c64, dim_t, f32, f64, intl
32+
export s16, s32, s64, u16, u32, u64, u8, uintl
3233

3334
const dim_t = Clonglong
3435
const intl = Clonglong
@@ -280,6 +281,20 @@ const AF_STORAGE_CSC = (UInt32)(2)
280281
const AF_STORAGE_COO = (UInt32)(3)
281282
# end enum af_storage
282283

284+
# begin enum af_flux_function
285+
const af_flux_function = UInt32
286+
const AF_FLUX_QUADRATIC = (UInt32)(1)
287+
const AF_FLUX_EXPONENTIAL = (UInt32)(2)
288+
const AF_FLUX_DEFAULT = (UInt32)(0)
289+
# end enum af_flux_function
290+
291+
# begin enum af_diffusion_eq
292+
const af_diffusion_eq = UInt32
293+
const AF_DIFFUSION_GRAD = (UInt32)(1)
294+
const AF_DIFFUSION_MCDE = (UInt32)(2)
295+
const AF_DIFFUSION_DEFAULT = (UInt32)(0)
296+
# end enum af_diffusion_eq
297+
283298
type af_seq
284299
_begin::Cdouble
285300
_end::Cdouble

src/wrap.jl

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22
# Automatically generated using Clang.jl wrap_c, version 0.0.0
33

44

5-
export abs, accum, acos, acosh, add, afinfo, afinit, afversion, all, all_true_all, alloc_device, and, any
6-
export any_true_all, approx1, approx2, arg, array_to_string, asin, asinh, assign_seq, atan, atan2, atanh
7-
export bilateral, bitand, bitor, bitshiftl, bitshiftr, bitxor, canny, cbrt, ceil, cholesky_inplace, color_space
8-
export complex, conj, convolve1, convolve2, convolve2_sep, convolve3, copy, corrcoef, cos, cosh, count
9-
export count_all, cov, create_features, create_handle, create_indexers, create_random_engine, create_sparse_array
10-
export create_sparse_array_from_dense, create_sparse_array_from_ptr, create_window, delete_image_memory
11-
export destroy_window, det, device_array, device_gc, device_mem_info, diag, diagm, diff1, diff2, dilate
12-
export dilate3, div, dog, dot, dot_all, draw_hist, draw_image, draw_plot, draw_plot3, draw_plot_2d, draw_plot_3d
13-
export draw_plot_nd, draw_scatter, draw_scatter3, draw_scatter_2d, draw_scatter_3d, draw_scatter_nd, draw_surface
14-
export draw_vector_field_2d, draw_vector_field_3d, draw_vector_field_nd, eq, erf, erfc, erode, erode3
15-
export exp, expm1, factorial, fast, flip, floor, free_device, full, gaussian_kernel, ge, get_active_backend
16-
export get_available_backends, get_backend_count, get_backend_id, get_data_ptr, get_dbl_support, get_default_random_engine
17-
export get_device, get_device_count, get_device_id, get_device_ptr, get_dims, get_elements, get_features_num
18-
export get_features_orientation, get_features_score, get_features_size, get_features_xpos, get_features_ypos
19-
export get_manual_eval_flag, get_mem_step_size, get_revision, get_seed, gloh, gradient, gray2rgb, gt, hamming_matcher
20-
export harris, hist_equal, histogram, homography, hsv2rgb, hypot, identity, imag, imax, imax_all, imin
21-
export imin_all, index, index_gen, inverse, iota, is_bool, is_column, is_complex, is_double, is_empty
22-
export is_floating, is_image_io_available, is_integer, is_lapack_available, is_locked_array, is_real, is_realfloating
23-
export is_row, is_scalar, is_single, is_vector, is_window_closed, isinf, isnan, issparse, iszero, le, lgamma
24-
export load_image, load_image_memory, load_image_native, lock_array, lock_device_ptr, log, log10, log1p
25-
export log2, lookup, lower, lt, lu, lu_inplace, make_seq, match_template, matmul, max_all, maxfilt, maximum
26-
export maxof, mean_all, mean_all_weighted, mean_shift, medfilt, medfilt1, medfilt2, median_all, min_all
27-
export minfilt, minimum, minof, mod, moments, moments_all, mul, nearest_neighbour, neq, norm, not, or
28-
export orb, pow, pow2, print_array, print_array_gen, print_mem_info, prod, product_all, product_nan, product_nan_all
29-
export qr, qr_inplace, random_engine_get_seed, random_engine_get_type, random_engine_set_seed, random_engine_set_type
30-
export random_normal, random_uniform, range, rank, read_array_index, read_array_key, read_array_key_check
31-
export real, regions, release_features, release_random_engine, rem, reorder, replace, replace, resize
32-
export retain_features, retain_random_engine, rgb2gray, rgb2hsv, rgb2ycbcr, root, rotate, round, sat, save_array
33-
export save_image, save_image_memory, save_image_native, scale, scan, scan_by_key, set_axes_limits_2d
34-
export set_axes_limits_3d, set_axes_limits_compute, set_axes_titles, set_backend, set_default_random_engine_type
5+
export abs, accum, acos, acosh, add, afinfo, afinit, afversion, all, all_true_all, alloc_device, and, anisotropic_diffusion
6+
export any, any_true_all, approx1, approx2, arg, array_to_string, asin, asinh, assign_seq, atan, atan2
7+
export atanh, bilateral, bitand, bitor, bitshiftl, bitshiftr, bitxor, canny, cbrt, ceil, cholesky_inplace
8+
export color_space, complex, conj, convolve1, convolve2, convolve2_sep, convolve3, copy, corrcoef, cos
9+
export cosh, count, count_all, cov, create_features, create_handle, create_indexers, create_random_engine
10+
export create_sparse_array, create_sparse_array_from_dense, create_sparse_array_from_ptr, create_window
11+
export delete_image_memory, destroy_window, det, device_array, device_gc, device_mem_info, diag, diagm
12+
export diff1, diff2, dilate, dilate3, div, dog, dot, dot_all, draw_hist, draw_image, draw_plot, draw_plot3
13+
export draw_plot_2d, draw_plot_3d, draw_plot_nd, draw_scatter, draw_scatter3, draw_scatter_2d, draw_scatter_3d
14+
export draw_scatter_nd, draw_surface, draw_vector_field_2d, draw_vector_field_3d, draw_vector_field_nd
15+
export eq, erf, erfc, erode, erode3, exp, expm1, factorial, fast, flip, floor, free_device, full, gaussian_kernel
16+
export ge, get_active_backend, get_available_backends, get_backend_count, get_backend_id, get_data_ptr
17+
export get_dbl_support, get_default_random_engine, get_device, get_device_count, get_device_id, get_device_ptr
18+
export get_dims, get_elements, get_features_num, get_features_orientation, get_features_score, get_features_size
19+
export get_features_xpos, get_features_ypos, get_manual_eval_flag, get_mem_step_size, get_revision, get_seed
20+
export gloh, gradient, gray2rgb, gt, hamming_matcher, harris, hist_equal, histogram, homography, hsv2rgb
21+
export hypot, identity, imag, imax, imax_all, imin, imin_all, index, index_gen, inverse, iota, is_bool
22+
export is_column, is_complex, is_double, is_empty, is_floating, is_image_io_available, is_integer, is_lapack_available
23+
export is_locked_array, is_real, is_realfloating, is_row, is_scalar, is_single, is_vector, is_window_closed
24+
export isinf, isnan, issparse, iszero, le, lgamma, load_image, load_image_memory, load_image_native, lock_array
25+
export lock_device_ptr, log, log10, log1p, log2, lookup, lower, lt, lu, lu_inplace, make_seq, match_template
26+
export matmul, max_all, maxfilt, maximum, maxof, mean_all, mean_all_weighted, mean_shift, medfilt, medfilt1
27+
export medfilt2, median_all, min_all, minfilt, minimum, minof, mod, moments, moments_all, mul, nearest_neighbour
28+
export neq, norm, not, or, orb, pow, pow2, print_array, print_array_gen, print_mem_info, prod, product_all
29+
export product_nan, product_nan_all, qr, qr_inplace, random_engine_get_seed, random_engine_get_type, random_engine_set_seed
30+
export random_engine_set_type, random_normal, random_uniform, range, rank, read_array_index, read_array_key
31+
export read_array_key_check, real, regions, release_features, release_random_engine, rem, reorder, replace
32+
export replace, resize, retain_features, retain_random_engine, rgb2gray, rgb2hsv, rgb2ycbcr, root, rotate
33+
export round, sat, save_array, save_image, save_image_memory, save_image_native, scale, scan, scan_by_key
34+
export set_axes_limits_2d, set_axes_limits_3d, set_axes_limits_compute, set_axes_titles, set_backend, set_default_random_engine_type
3535
export set_device, set_intersect, set_manual_eval_flag, set_mem_step_size, set_position, set_seed, set_size
3636
export set_title, set_union, set_unique, set_visibility, shift, show, sift, sigmoid, signbit, sin, sinh
3737
export skew, sobel_operator, solve, solve_lu, sort_by_key, sparse_convert_to, sparse_get_col_idx, sparse_get_info
@@ -1509,6 +1509,12 @@ function canny{T,N}(_in::AFArray{T,N},threshold_type::af_canny_threshold,low_thr
15091509
AFArray{T,N}(out[])
15101510
end
15111511

1512+
function anisotropic_diffusion{T,N}(_in::AFArray{T,N},timestep::Cfloat,conductance::Cfloat,iterations::Integer,fftype::af_flux_function,diffusion_kind::af_diffusion_eq)
1513+
out = RefValue{af_array}(0)
1514+
_error(ccall((:af_anisotropic_diffusion,af_lib),af_err,(Ptr{af_array},af_array,Cfloat,Cfloat,UInt32,af_flux_function,af_diffusion_eq),out,_in.arr,timestep,conductance,UInt32(iterations),fftype,diffusion_kind))
1515+
AFArray{T,N}(out[])
1516+
end
1517+
15121518
function svd_inplace(_in::AFArray)
15131519
u = RefValue{af_array}(0)
15141520
s = RefValue{af_array}(0)

0 commit comments

Comments
 (0)