Hough Circle Transform

365 views
Skip to first unread message

Joseph Wang

unread,
Aug 8, 2018, 5:09:53 PM8/8/18
to Bonsai Users
I am trying to detect pupil size using the HoughCircles node in Bonsai. There was a previous post about this where a PythonTransform node was used. However, I would like to use HoughCircles, as I heard it is more powerful and can detect circles that are partially occluded (covered up). Plus, I have already successfully used a Hough transform to measure pupil size in ImageJ. 

In Bonsai, I have cropped the video and thresholded it for the pupil, yet Hough Circles seems not to work. What am I doing wrong?

Attached are my Bonsai workflow and the video I am analyzing. 
Hough Transform.bonsai
Pupil.mp4

Gonçalo Lopes

unread,
Aug 14, 2018, 5:42:12 AM8/14/18
to Joseph Wang, Bonsai Users
Hi Joseph,

If you change the threshold values of HoughCircles (Param1 and Param2) to lower values (e.g. 20 and 10), it should give you a bunch of circles. Does this work for you?

The tricky thing with HoughCircles is that I personally find it hard to tweak. It may be worth it to integrate better circle estimation methods in Bonsai. Let us know if you have any ideas, we would be interested in having more robust techniques for this kind of tracking built into the vision package.

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/bonsai-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/388a0d16-2ec6-4e95-94ca-deb383021437%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joseph Wang

unread,
Aug 14, 2018, 12:56:39 PM8/14/18
to Bonsai Users
Hi Goncalo, 

Thanks for the reply! Lowering the parameter values did work. 

I noticed that the HoughCircles node only returns perfect circles. I used a Hough Transform in Fiji (ImageJ) before, and it was able to return circles of varying curvature, where curvature = 1 is a perfect circle and curvature = 0 is a perfect line. In Fiji, I was able to set a minimum curvature (0.5), so that it would often return ellipses for the pupil, more accurately modeling it.

However, that doesn't seem to be the case in Bonsai, which has both a HoughCircles and a HoughLines node. It seems like Bonsai can only detect perfect circles and perfect lines and not anything in between. Is that true?

If so, would it be possible to create a HoughTransform node with curvature as one of its properties?

On Tuesday, August 14, 2018 at 4:42:12 AM UTC-5, goncaloclopes wrote:
Hi Joseph,

If you change the threshold values of HoughCircles (Param1 and Param2) to lower values (e.g. 20 and 10), it should give you a bunch of circles. Does this work for you?

The tricky thing with HoughCircles is that I personally find it hard to tweak. It may be worth it to integrate better circle estimation methods in Bonsai. Let us know if you have any ideas, we would be interested in having more robust techniques for this kind of tracking built into the vision package.
On 8 August 2018 at 22:09, Joseph Wang <joseph...@gmail.com> wrote:
I am trying to detect pupil size using the HoughCircles node in Bonsai. There was a previous post about this where a PythonTransform node was used. However, I would like to use HoughCircles, as I heard it is more powerful and can detect circles that are partially occluded (covered up). Plus, I have already successfully used a Hough transform to measure pupil size in ImageJ. 

In Bonsai, I have cropped the video and thresholded it for the pupil, yet Hough Circles seems not to work. What am I doing wrong?

Attached are my Bonsai workflow and the video I am analyzing. 

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.

Gonçalo Lopes

unread,
Aug 22, 2018, 5:37:27 AM8/22/18
to Joseph Wang, Bonsai Users
Hi Joseph,

You are correct, the output of HoughCircles is always a perfect circle. However, you can still fit the curvature of the circle to an imperfect non-circular elliptical object. For example:



For some situations this does help, however if your object is really elliptical in nature it will not be appropriate. Also, HoughCircles often brings up an excessive number of false positives which can be hard to deal with. I'm not sure which Hough transform algorithm is used by ImageJ, but in general the Hough transform is not the best approach for arbitrary curvature tracking.

For now, unfortunately, you might need to develop a custom script. Let us know if you make any progress on this.

To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.

Kaushik More

unread,
Aug 27, 2020, 12:13:35 PM8/27/20
to Bonsai Users
Hey Joseph,
I'm trying to detect pupil size and change for a project. However, the image I'm acquiring is not as clear as you have. Are you processing the video capture in some way in Bonsai before converting it to grayscale or just raw capturing it? 
If its raw capture, can you share the details of your hardware, i.e. camera, IR lamp etc. It would be quite helpful. Thank you !
Reply all
Reply to author
Forward
0 new messages