File Exchange

image thumbnail

Spherical hough transform for 3D images

version 1.4.0.0 (2.4 MB) by Luke Xie
SphericalHough detects spherical structures from 3D images - determines object center and radius

15 Downloads

Updated 22 Oct 2014

View License

SPHERICALHOUGH detects spherical structures from 3D images. Determines object centers and radii and outputs image mask of centers and spheres. This hough transform is based on the gradient field of the image. The code is heavily based off of Circular Hough Transform by Tao Peng (see info below).


USAGE:
[center_img,sphere_img,sphcen2,sphrad]=SPHERICALHOUGH(
img,radrange,grdthres,fltrLM_R,multirad,obj_cint)


EXAMPLE:

Run Example.m to see demonstration of SphericalHough on 3D MRI data of a rat kidney. It demonstrates the detection of kidney glomeruli, which are roughly spherical at 31x31x31 um^3 resolution. The expected radii are between 2 to 7 pixels. Example data is from the following article: MRH of age-related nephropathy, Tox Path, 2012 Jul;40(5):764-78 (http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3515870)
Supplemental material is also available on CIVMspace: http://www.civm.duhs.duke.edu/lx201107
Essential support functions are included for the example. Complete support functions can be found at the websites below:
SphericalHough http://www.mathworks.com/matlabcentral/fileexchange/48219
ordfilt3 http://www.mathworks.com/matlabcentral/fileexchange/22044
load_nii http://www.mathworks.com/matlabcentral/fileexchange/8797
showsrs2 http://wiki.biac.duke.edu/biac:tools


2007_03_07 original Circular Hough Transform by Yao Peng
2010_08_25 Spherical Hough Transform by Brian Hulette
2014_10_20 simpification, filtration, image mapping, classifiers, and example by Luke Xie

Comments and Ratings (16)

matnewbie

Is it possible to extend this routine to detect other shapes, like cylinders in a 3D image?

sally

does this algorithm require the object being a perfect square? or just sphere like shape even if a bit distorted or connected to another tabular structure (like lung nodules in 3d CT scans) ? also, dows it require a binary image or gray-scale image, or both can be handled?

GUO bill

Nickolay

layyybfk

Thank you very much.
I replaced the code but now I get the following:

Index exceeds matrix dimensions.

Error in SphericalHough (line486)
x=x+sphcen(ind,1);

Can you help me?
Thanks a lot!
I am facing with the same problem.

Konstantin

Thank you for the quick response.
I replaced the code but now I get the following:

Index exceeds matrix dimensions.

Error in SphericalHough (line486)
x=x+sphcen(ind,1);

Can you help me again?
Thanks a lot!

Luke Xie

Replace that line with the following. I hope to update the code later.

% NEW TO FIX "out of range subscript" prob due to x,y,z 0 or above
% d1,d2,d3
y=round(y); x=round(x); z=round(z);
y(y>d1)=d1; x(x>d2)=d2; z(z>d3)=d3;
y(y<1)=1; x(x<1)=1; z(z<1)=1;
% ==========
tmp=sub2ind([d1,d2,d3],y,x,z);

Konstantin

Hello Luke Xie,

thank you for your code.
I try to detect spherical grains in an image (3D grayscale). By using the code I get the following error:

Error in using sub2ind (line 73)
Out of range subscripts.
Error in SphericalHough (line489)
tmp=sub2ind([d1,d2,d3],round(x),round(y),round(z));

Do you know what's wrong?
Thanks for your help!

Carl

Hello Lukie Xie,

Just one more question. Suppose a sphere is successfully constructed from the function, the radius and center of the sphere ared estimated, are we able to obtain the list of 3d points corrsponding to the consturction of the sphere?

It is because I would liek to know how good my sphereis when compare to my points.

The most obviously method would be to take the average of sum of different between each point and the contructed sphere (suppose I take the shortest distance between the 3d Points the the spherical surface)

Luke Xie

Hello Carl,
The code is designed for detecting spheres in image space. You will have to place those 3D coordinates into discrete matrix form. If you look at the end of SphericalHough.m you will find how to place coordinate points into a 3D matrix.

Carl

Hello Luke Xie,

If I have a list of 3d Point, I would like to construct and detect the sphere. Will this algorithm you suggested here also works?

Luke Xie

Hello Niamul,
Thank you for your comments. The code does need the range of radii as an input. The general guideline is to set a small range for faster computing but a large enough range to cover expected radii. Please post what error you received.

Hello Xie,

Thank you for this nice implementation.

I tried your example and ran into some difficulties. In particular, whenever I change the radius range to other values (e.g. 22 and 27), the code results in error notifications. Could you check how I could solve this? Is there a guideline onto how I should chose the range of radius?

Thanks.

Luke Xie

Hello Oli,
Parts of the code can be used to identify the centroid of objects. Determining the radii would be much more difficult. You may want to treat your problem as individual 2D slices and use a circular hough transform: http://www.mathworks.com/matlabcentral/fileexchange/9168

Oli

Hi,

Would this be able to cope with anisotropic resolution in the images? Typically 3D microscopy data has a higher resoltion in the lateral directions (XY) than in the axial direction (Z) in the range of 2-6 fold.

We can interpolate the data to make it isotropic, but this increases the image size considerably.

Thanks for your time

Updates

1.4.0.0

added more input validation, changed gradient threshold input to a ratio, inverted object center intensity threshold

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

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor

SUPPORT_NIfTI_20140122/

SUPPORT_biactools_0.93/general/

SUPPORT_biactools_0.93/general/@url/

SUPPORT_biactools_0.93/general/private/

SUPPORT_biactools_0.93/mr/