Code covered by the BSD License  

Highlights from
Nonlinear Coupled Diffusion

Be the first to rate this file! 34 Downloads (last 30 days) File Size: 159.36 KB File ID: #27604
image thumbnail

Nonlinear Coupled Diffusion

by Omid Aghazadeh

 

13 May 2010 (Updated 18 May 2010)

This package implements isotropic nonlinear scalar valued/ coupled vector/matrix valued diffusion.

| Watch this File

File Information
Description

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.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Nonlinear Diffusion Toolbox, Sparse set of Features for Texture Discrimination
This submission has inspired the following:
Sparse set of Features for Texture Discrimination

MATLAB release MATLAB 7.9 (2009b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
05 Jul 2010 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);

05 Jul 2010 Omid Aghazadeh

Try compiling the missing mex file:
mex thomas_mex.cpp

06 Jul 2010 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?

07 Jul 2010 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.

15 Jul 2010 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[])
{
....
}

Please login to add a comment or rating.
Updates
15 May 2010

Criterion for keeping the total mass constant was lacking an abs.

18 May 2010

Implemented the Thomas algorithm in mex and made some modifications for the case of left-right neighbors to make AA exactly tri-diagonal.

Tag Activity for this File
Tag Applied By Date/Time
nonlinear diffusion Omid Aghazadeh 14 May 2010 09:26:42
pde based image processing Omid Aghazadeh 14 May 2010 09:26:42
image processing Omid Aghazadeh 14 May 2010 09:26:42
image denoising Omid Aghazadeh 14 May 2010 09:26:42
image enhancement Omid Aghazadeh 14 May 2010 09:26:42
total variation tv flow Omid Aghazadeh 14 May 2010 09:26:42
edge enhancing flow Omid Aghazadeh 14 May 2010 09:26:42
aos Omid Aghazadeh 14 May 2010 09:26:42

Contact us at files@mathworks.com