Code covered by the BSD License  

Highlights from
Image Edge Enhancing Coherence Filter Toolbox

4.88889

4.9 | 9 ratings Rate this file 101 Downloads (last 30 days) File Size: 10.1 MB File ID: #25449
image thumbnail

Image Edge Enhancing Coherence Filter Toolbox

by

 

30 Sep 2009 (Updated )

Advanced 2D/3D noise removal and edge enhancing with anisotropic diffusion filtering ( Weickert )

| Watch this File

File Information
Description

Introduction:
This toolbox will perform Anisotropic Non-Linear Diffusion filtering on a 2D gray/color or 3D image. This filtering will reduce the image noise while preserving the region edges, and also enhancing the edges by smoothing along them.

This is one of the more advanced image enhancement methods available, and also contains HDCS from october 2009. The result looks like an artist painted the image, with clear brush strokes along the image edges and ridges, see screen-shot.

My papers about the code are included:
- "Coherence Filtering to Enhance the Mandibular Canal in Cone-Beam CT Data", IEEE-EMBS Benelux Chapter Symposium, 2009.
- "Optimized Anisotropic Rotational Invariant Diffusion Scheme on Cone-Beam CT", MICCAI, 2010

Method:
The basis of the method used is the one introduced by Weickert.
1, Calculate Hessian from every pixel of the Gaussian smoothed input image
2, Gaussian Smooth the Hessian, and calculate its eigenvectors and values (Image edges give large eigenvalues, and the eigenvectors corresponding to those eigenvalues describe the direction of the edge)
3, The eigenvectors are used as diffusion tensor directions. The amplitude of the diffusion in those 3 directions is based on the eigen values and determined by Weickerts equation.
4, An Finite Difference scheme is used to do the diffusion
5, Back to step 1, till a certain diffusion time is reached.

Diffusion schemes:
There are several diffusion schemes available: standard, implicit, nonegative discretization, and also a rotation invariant scheme, and a novel diffusion scheme with new optimized derivatives.

Mex Files:
All 3D files are not only available as Matlab but also as C-code /MEX files, to increase speed and reduce the amount of memory used. Compile the c-code by executing compile_c_files.m.

Literature (Full list in the included paper):
- Weickert : "A Scheme for Coherence-Enhancing Diffusion Filtering with Optimized Rotation Invariance"
- Mendrik et al, "Noise Reduction in Computed Tomography Scans Using 3-D Anisotropic Hybrid Diffusion With Continuous Switch", October 2009
- Weickert : "Anisotropic Diffusion in Image Processing", Thesis 1996
- Laura Fritz : "Diffusion-Based Applications for Interactive Medical Image Segmentation"
- Siham Tabik, et al. : "Multiprocessing of Anisotropic Nonlinear Diffusion for filtering 3D image"

Usage:
Read the help of CoherenceFilter, compile the c-code and try the examples in the help.

Please report bugs, successes and questions.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (26)
30 Jan 2014 Christopher

I'd like to agree with / confirm Michelle's comment. compile_c_files gives an error " mex: no file name given." unless you change "diffusion_scheme_3D_novel_getUpdate" to "diffusion_scheme_3D_novel_getUpdate.c"
Thanks!

10 May 2013 Michele

Hi,
there's a little typo in compile_c_files.m.
Last file to be compiled has not the .c extension.
This: "diffusion_scheme_3D_novel_getUpdate.c"
Thanks.

20 Mar 2013 Sourin

solved! it was some mac os problem with gcc!

20 Mar 2013 Sourin

Hi

I am getting the allowing error…. any help is greatly appreciated. I am using matlab 2012b on Mac os. thanks

Sourin

derivatives.c: In function 'gradient2Dx':
derivatives.c:24: warning: incompatible implicit declaration of built-in function 'malloc'
derivatives.c: In function 'gradient2Dy':
derivatives.c:57: warning: incompatible implicit declaration of built-in function 'malloc'
derivatives.c: In function 'gradient3Dx_double':
derivatives.c:110: warning: incompatible implicit declaration of built-in function 'malloc'
derivatives.c: In function 'gradient3Dx_float':
derivatives.c:195: warning: incompatible implicit declaration of built-in function 'malloc'
derivatives.c: In function 'gradient3Dy_float':
derivatives.c:280: warning: incompatible implicit declaration of built-in function 'malloc'
derivatives.c: In function 'gradient3Dz_float':
derivatives.c:364: warning: incompatible implicit declaration of built-in function 'malloc'
derivatives.c: In function 'gradient3Dy_double':
derivatives.c:449: warning: incompatible implicit declaration of built-in function 'malloc'
derivatives.c: In function 'gradient3Dz_double':
derivatives.c:533: warning: incompatible implicit declaration of built-in function 'malloc'

mex: compile of ' "derivatives.c"' failed.

Error using mex (line 206)
Unable to complete successfully.

Error in compile_c_files (line 8)
mex(filename,'-v');

18 Mar 2013 Anton Semechko

When filtering 3D images I noticed that there is not option to specify the voxel resolution. To me this implies that in creating this function the author assumed that the voxels of the input image have isotropic resolution. Unfortunately this is usually not the case and must be accounted for when discretizing the diffusion equation.

Aside from this, I think this is a great submission. Many thanks!.

27 Sep 2012 Ron

The original stencel can be found here:
http://www.scribd.com/doc/52387266/Jahne-B-Handbook-of-Computer-Vision-and-Applications-Vol-2-Signal-Processing-and-Pattern-Recognition

27 Sep 2012 Ron

Hi,

I have found an error in the code.
The 2D "standard" diffusion algorithm may be incorrect. The stencil shown in Weickertt (2002) is not the same as that referenced (from the handbook volume 2). That stencil has both terms in the top-left and bottom left corners negative. I beleive it is a typo in the Weickertt paper unless I am missing something.

27 Sep 2012 Ron

Hi,

I have found an error in the code.
The 2D "standard" diffusion algorithm may be incorrect. The stencil shown in Weickertt (2002) is not the same as that referenced (from the handbook volume 2). That stencil has both terms in the top-left and bottom left corners negative. I beleive it is a typo in the Weickertt paper unless I am missing something.

06 Jul 2012 leila

I think it is useful to explain how to tune the parameters and constants. The default configuration over-smooth my image. I have a very thin object in a noisy image that disappeared by the filter.
thank you.

06 Jul 2012 leila

hi, can I request everyone to report run-time of their experiment and size of image volume.
thanks.

02 Apr 2012 Courosh Mehanian

where can imresize2 (that's called in hessian) be found?

28 Mar 2012 xiuhong

it is a useful tool. Thanks the author very much!

23 Nov 2011 ITTelkom  
09 Oct 2011 Sun SHENG

it is a elaborate tool. it is very usefull to my research. Thanks the author a lot!

15 Apr 2011 Matthias Schabel

To solve the mex compilation error :

on OSX, add the following as line 3 of diffusion_scheme_3D_novel_getUpdate.c :

#include "string.h"

and re-run the mex script

17 Feb 2011 Wouter

Compliments for this excellent code

I experience the same problem as Anthony Kilburg:

diffusion_scheme_3D_novel_getUpdate.c:126: warning: incompatible implicit declaration of built-in function 'memcpy'

Probably due to OS X or my compiler? (gcc-4.2)

Google 'says' I have to include <String.h>, but this does not seems to solve it.

01 Feb 2011 Ding Yuan

Dirk,

Thanks for sharing, your profession in matlab is very impressive. the package is really nonlinear anisotropic diffusion, not only coherence diffusion, so I strongly suggest changing the name. I found a problem in functions2D/EigenVectors2D.m the eigenvectors v1 v2 corresponds to mu2 and mu1, please check it, it can be a serious bug.

18 Jan 2011 Anthony Kilburg

Hello,

I reached an error while attempting to compile the C-code files. Error message is as follows:

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

Error in ==> compile_c_files at 32
mex diffusion_scheme_3D_novel_getUpdate -v;

Upon review of the code I downloaded, I found that all mex funtions call for the function name .c -v for all the except the function I am having trouble with. Is the call in the function meant to be:
mex diffusion_scheme_3D_novel_getUpdate.c -v;

Thank you

30 Nov 2010 wang ning

in diffusion_scheme_3D_standard.c , /* Compute tensor-driven diffusion (as in [1] pp. 80-82) */ which Literature is quoted ? What's [1] ?

23 Mar 2010 nurul

hi sir,
i just downloaded ur work. i find an error on line 218 . it says
Error in ==> CoherenceFilter at 218
if(size(u,3)<4), u=double(u); else u=single(u);

22 Nov 2009 bin yao

A great code for studying diffusion filtering implementation. Thanks a lot for sharing.

I have two questions about the scheme
1) implicit scheme : does it means using semi-implicit AOS scheme to implementation?

2) diffusion_scheme_3D_implicit.m , you said "!! Scheme is unstable, and not ready to use yet." what is the problem?

02 Oct 2009 Dirk-Jan Kroon

I uploaded a new version with derivative boundary check bug fixed, probably tomorrow online. thnx Elmar.

02 Oct 2009 Dirk-Jan Kroon

*Elmar
Thank you for sharing the solution for your NaN problem.
Now, I know it's probably caused by a boundary check problem.

Dirk-Jan

01 Oct 2009 Elmar

I permuted the directions of the volume so that it is 147x227x227, now it works perfectly

01 Oct 2009 Dirk-Jan Kroon

* Elmar,

Thank you for your report, I never experienced NaN's my self.
Maybe you can add a small value to rule out division by zero.

If you still have problems, maybe you can share a part of the volume data with me?

Thanx, Dirk-Jan

01 Oct 2009 Elmar

Thanks for sharing this tool! works very well and fast, but i'm experiencing some problems:
I'm trying to filter a 3D MRI volume of size 227x227x147. Depending on the value of 'rho' I use I get a variable number of slices in the third dimension that are all 'NaN'. The bigger rho, the more NaN slices are in the output image volume. For every value of T used the number of NaN-slices accumulates, so that after several timesteps the whole image volume consists of NaNs.
What could be the reason for the NaNs in the output?

My original image is single and normalized to a range of 0 to 1 and does not contain any NaNs.
thx, Elmar

Updates
01 Oct 2009

Tested Linux Ubuntu

02 Oct 2009

Fixed boundary check bug in backward derivatives.

19 Oct 2009

Literature

17 Nov 2009

Added Adriënne M. Mendrik et al. "Hybrid Diffusion with Continuous Switch (HDCS)", october 2009 IEEE transactions on medical imaging.

17 Nov 2009

LCC compiler fix

02 Feb 2010

Added new Diffusion scheme which uses optimized 5x5 second order derivatives...

06 Sep 2010

Added paper, some minor changes in values

Contact us