File Exchange

image thumbnail

Nonlinear Coupled Diffusion

version 1.2.0.0 (159 KB) by Omid Aghazadeh
This package implements isotropic nonlinear scalar valued/ coupled vector/matrix valued diffusion.

4 Downloads

Updated 18 May 2010

View Version History

View License

The code supports homogeneous and linear and nonlinear (Total Variation and Edge Enhancing flow) isotropic diffusion of arbitrary dimensioned fields(scalar~grayscale image, vector ~ color image and matrix~structure tensor). Additive Operator Splitting(AOS) as well as Gaussian regularization are implemented to speedup the computations.
Two point 1 sided differences is implemented for spatial discretization which is more accurate than the central differences. A semi implicit time discretization as well as epsilon regularization is utilized to make the diffusion process stable for arbitrary time-step sizes. The code is commented, the definition and dimensions of the input/output variables can be found in the header of the nonlinear_diffusion.m. A sample script is provided to visualize the diffusion process of two sample images.
The AOS implementation uses the Thomas algorithm implemented in mex to achieve the fastest speed.

Cite As

Omid Aghazadeh (2020). Nonlinear Coupled Diffusion (https://www.mathworks.com/matlabcentral/fileexchange/27604-nonlinear-coupled-diffusion), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

Amitava Biswas

Xizhi

It works well despite of low speed. I am trying to figure out the way to de-noise color image using edge enhancing diffusion while the referenced literature are a bit confusing to me.

Omid Aghazadeh

I encountered the same problem in linux. It seems that gcc is sensitive to the signiture of the mexFunction having a const for the prhs parameter:
in the mex file, change the header to :

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
....
}

Omid Aghazadeh

The mex function is as simple as it gets, a few multiplications and additions and I'm sure that it compiles using Microsoft Visual Studio 2008 c++ compiler. I'm not sure what the problem is but it might be the lcc compiler. Maybe you can try gnu compiler or MSVC c++ compiler.

reira wiratih

I've compiled the command "mex thomas_mex.cpp ", but I got this:

lcc preprocessor warning: thomas_mex.cpp:31 No newline at end of file
Error thomas_mex.cpp: 4 redeclaration of `mexFunction' previously declared at C:\PROGRA~1\MATLAB\R2009A\extern\include\mex.h 142
Error thomas_mex.cpp: 7 illegal statement termination
Error thomas_mex.cpp: 7 skipping `double'
Error thomas_mex.cpp: 7 undeclared identifier `a'
Error thomas_mex.cpp: 7 type error: pointer expected
Error thomas_mex.cpp: 7 operands of = have illegal types `int' and `pointer to double'
Error thomas_mex.cpp: 7 illegal statement termination
Error thomas_mex.cpp: 7 skipping `double'
Error thomas_mex.cpp: 7 undeclared identifier `b'
Error thomas_mex.cpp: 7 type error: pointer expected
Error thomas_mex.cpp: 7 operands of = have illegal types `int' and `pointer to double'
Error thomas_mex.cpp: 7 illegal statement termination
Error thomas_mex.cpp: 7 skipping `double'
Error thomas_mex.cpp: 7 undeclared identifier `c'
Error thomas_mex.cpp: 7 type error: pointer expected
Error thomas_mex.cpp: 7 operands of = have illegal types `int' and `pointer to double'
Error thomas_mex.cpp: 7 illegal statement termination
Error thomas_mex.cpp: 7 skipping `double'
Error thomas_mex.cpp: 7 undeclared identifier `d'
Error thomas_mex.cpp: 7 type error: pointer expected
Error thomas_mex.cpp: 7 too many errors

C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Compile of 'thomas_mex.cpp' failed.

??? Error using ==> mex at 218
Unable to complete successfully.

what should I do?

Omid Aghazadeh

Try compiling the missing mex file:
mex thomas_mex.cpp

jichao zhao

something wrong in the code:

test_nonlinear_diffusion
Mex file entry point is missing. Please check the (case-sensitive)
spelling of mexFunction (for C MEX-files), or the (case-insensitive)
spelling of MEXFUNCTION (for FORTRAN MEX-files).
??? Invalid MEX-file '/Nonlinear_Diffusion/thomas_mex.mexa64': .

Error in ==> Nonlinear_Diffusion>solve_tridiagonal at 168
U = thomas_mex(b,c,a,U)';

Error in ==> Nonlinear_Diffusion>solve_semi_implicit_scheme at 202
U_bt = solve_tridiagonal(U((ixstart+1):(ixstart+N)),gs,ix_v,ix_v+N,ix_v+4*N,ixy,ixx,N,ax,tau,2); % top and bottom

Error in ==> Nonlinear_Diffusion at 118
[U] = solve_semi_implicit_scheme(U,g_arg_sq,ix_v,N,d,w,ax,tau,p,eps2,ixx,ixy,ix_ch_lr);

Error in ==> test_nonlinear_diffusion at 5
[Zebra1] = Nonlinear_Diffusion(double(zebra),1,1e-2,1,20,0, 0);

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!