[SciPy-user] canny1d filter?

Zachary Pincus zachary.pincus@yale....
Sat Apr 25 17:24:38 CDT 2009

>> I can send you code for a 2D Canny filter that uses numpy and
>> scipy.ndimage to good effect. It's a decent demonstration of the
>> filter, and of how to make good use out of the tools in ndimage.
> Can you send it, please? I would really appreciate...

Attached. The implementation of the hysteresis thresholding bit is  
worth noting, because the technique for doing this with ndimage was  
not obvious to me at first, but has proven quite useful in general: I  
use the lower threshold to make a mask, and then dilate the edge map  
thresholded at the higher threshold for -1 iterations (which makes  
ndimage keep dilating until no pixels change), using the lower  
threshold mask to constrain the dilation. This has the effect of  
"growing out" the regions that pass the higher threshold out into  
regions above the lower threshold. (I'm pretty sure this is a standard  
operation, given that it's available in ndimage, but like I said, it  
was not obvious to me at first.) Other than that, the implementation  
is basically straight from the wikipedia entry.

>> However, I don't think that Canny edge-detection, as I understand it,
>> is applicable to 1D signaling. Basically, Canny filtering finds the
>> gradient magnitude and direction in an image, and then uses the
>> direction information to thin out edges except along their "ridges".
>> It then uses a hysteresis thresholding approach to link the edges (by
>> finding seeds with a stringent threshold, and then extending the  
>> seeds
>> out along the edges using a less-stringent threshold). None of this
>> stuff makes sense in the 1D case -- there's no "edge direction", etc.
> I see... I still have to read the original Canny paper, but AFAIK he
> used a 1d example in it (but I may be wrong...)

I just looked over the paper -- there are plenty of 1D examples and  
calculations, but I think the results from that part aren't that  
useful: basically it says that there's a theoretical reason to use a  
DoG as the edge filter. It's probably interesting to read through the  
logic, because if your problem setting is different, then you could  
see if a different filter shape is optimal for what you're looking  
for. But as far as the "canny filter" as anyone would implement it,  
it's a 2D-only thing, because his real contribution was the 2D post- 
processing after doing a DoG.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: canny.py
Type: text/x-python-script
Size: 2174 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20090425/ecbf730e/attachment.bin 
-------------- next part --------------

More information about the SciPy-user mailing list