File Exchange

image thumbnail

Neuron counting

version (11.4 KB) by EMC_solver
Count the number of fluorescent cells (tagged with GFP) on noisy background fluorescence


Updated 05 Mar 2010

View License

% Matlab GUI for neuron counting
% frequency filtering to remove background fluorescence
% Otsu's method for thresholding, with user interaction
% Original image courtesy of Lan Guo

Cite As

EMC_solver (2020). Neuron counting (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (11)


@Hirak sorry to let you guys down. quite busy these years. it is a past project I did for my ex gf.

Hirak Mazumdar

kindly upload it correctly. lots of student depends on your file.


every button returns an error.


I really like the idea here, but I found too many problems right from the beginning. Every button that I push besides "browse" in the GUI returns an error.

To me, it's just not worth the time to dig through the code and try to fix this.


could you help me for making the 1- Please count number of peperoni. Using a GUIDE GUI based matlab function
your program is very useful to me.



have you tried distance transformation before WST? there is a Matlab function BWout=bwdist(BWin).
i got this from my class notes by Prof. Alex Hartov


hi, Rob
sorry for rating my own code. it is really not my purpose. i thought you have to click 'submit' for the rating to come out. and i haven't found a way to delete it.
you are right about the data type. it is really something i should consider.
the property of the slide bar can be changed in the GUI. select the slide bar, right click and select property inspector, and change the min and max value to expend the range. you might get an error when the threshold value is negative or more than one. i am not sure if it will help.
i'll also comment out the top hat part. i have a newer version GUI but don't want to upload it since it is really a minor change.

have you considered resizing your image before processing? enlarge them so each cell will have more pixel?

Rob Campbell

Thanks, I had looked at that link in the past. My problem is rather difficult because the cell bodies as small so I have few pixels to work with. Although they are touching, the pears are fairly easy to isolate because each pear is composed of a large number of pixels.

Your new GUI isn't working for me. It doesn't check whether the input is of the right type. e.g. my image was an int8 and under those circumstances the threshold slider doesn't work. I edited the code to convert the image to a double after loading but then something else broke.

You will find other users of this site consider it bad form for an author to rate their own submissions.


hi, Rob
thank you for the comments. that is what i am looking for.

i just uploaded a new GUI. hope you'll find it more user friendly.
to answer your question about the filtering parameter, it (i.e., the slide bar) changes the threshold values in the conversion from gray to BW.
if the bodies are touching, maybe the following link is useful to you

thank you

Rob Campbell

Useful if cells are well separated but won't work for images were many cell bodies are touching. This problem is, naturally, difficult to solve.

GUI not particularly user friendly since it isn't obvious that buttons need to be pressed in a particular order. I can't see how filtering parameters can be changed from within the GUI.


new GUI interface, tophat for preprocessing, optional outlining colors

include colormap for color image display

GUI version was made

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

Inspired by: Image overlay