New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blob Detection ( DoG ) - Resubmitting #903
Conversation
|
||
""" | ||
# computing max filter using all neighbors in cube | ||
fp = np.ones((3, 3, 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function can and should be made nd and take a connectivity parameter (so you can use 6 neighbors, 18, or 26; I prefer to refer to these as connectivity = 1, 2, 3), by using scipy.ndimage.generate_binary_structure. Then it might be useful as a public function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should we keep it in the API ? skimage.feature.get_local_maxima_3d
?
It also takes connectivity as a paramater now
@jni |
|
||
""" | ||
# computing max filter using all neighbors in cube | ||
fp = generate_binary_structure(3, connectivity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vighneshbirodkar, thanks, additional changes:
- change
array
to more commonly usedim
,img
orar
. (array
can be confused with the classnp.array
.) - use
ar.ndim
instead of 3 as the rank, and rename function to justget_local_maxima
, which now works in nd. - change docstring under
connectivity
to specify that number of neighbors is an example for 3D arrays. - I think exposing this under
feature
is not bad, but not great either. I might favormorphology
. @stefanv what do you think? Pigeonholes are hard... =) - Maybe add a doctest example showing the output for a 2D, 5x5 image with two local maxima.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not incorporate this into skimage.feature.peak_local_max?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahojnnes I think peak_local_max
is doing a lot of extra things which are unnecessary for the specific operation of blob detection. And it's also doing a lot of operations assuming that the input is a 2D array
Should I leave it here and import it in |
The function should only be made available from one place, otherwise it gets confusing. I would favor keeping it in BTW, thanks for all your work on this PR! I've been watching from the sidelines. I know it can be a lot of work the first time around, but the review process really improves the quality of the code base and makes it much easier for everyone who reads it weeks, months, or years down the road. |
@ahojnnes Do you have any opinion about the peak finder? |
I was also thinking of implementing other blob detection algorithms mentioned in the wiki. Should I add them to this PR ? Or wait for this one to get merged and add them in the next ? |
# https://github.com/adonath/blob_detection/tree/master/blob_detection | ||
|
||
|
||
def get_local_maxima(ar, threshold, connectivity=3): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for asking again, but what does this function provide that skimage.feature.peak_local_max
does not provide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skimage.feature.peak_local_max
assumes that input is an image, where as get_local_maxima
can work with any array ( a 3d array in case of blob detections )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion we should add the 3D functionality to peak_local_max... There is no reason to separate this functionality in two functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
peak_local_max
does a lot of other things than just find peaks, and we don't want it just for the 3D case, as @jni said, if the function operates on an ND array, it's useful as a public function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the question is whether it is worth duplicating functionality here.
Would it be possible to update the existing peak finder for N-d, or would
that be prohibitively expensive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing that is the case, especially handing the case where peak_local_max
excludes the border of the input array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I still don't understand why peak_local_max would not work with N-D arrays... I just tested:
In [1]: from skimage.feature import peak_local_max
In [2]: import numpy as np
In [3]: a = np.zeros((20, 20, 20))
In [4]: a[10, 10, 10] = 1
In [5]: peak_local_max(a, min_distance=1)
Out[5]: array([[10, 10, 10]])
Though, when looking at the code, there might be a bug in the logic of exclude_border
, shouldn't we set the values to -INF in lines 136, 137?
@ahojnnes You are right, I switched to |
@everyone, if peak_local_max works in nd, the documentation of that On Sunday, March 9, 2014, Coveralls notifications@github.com wrote:
|
@jni Please file an issue to keep track. |
# http://www.cs.utah.edu/~jfishbau/advimproc/project1/ (04.04.2013) | ||
# Theory behind: http://en.wikipedia.org/wiki/Blob_detection (04.04.2013) | ||
|
||
# A lot of this code is borrowed from here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are ready to merge. Please replace these two lines with entries for yourself and @adonath in CONTRIBUTORS.txt.
@stefanv I will implement the remaining blob detection algorithms in subsequent PRs and then add an example |
Thanks, @vighneshbirodkar! Fantastic work. |
Thank you! Please cc me if you make a new PR with the Hubble deep field example later. |
@stefanv @vighneshbirodkar : I went through the conversation in the previous PR about returning sigma and I think it should be returned as well as the fourth column. Its true that the area is more generic while sigma is specific to specific blob detectors, but then again I guess we are having different |
@ankit-maverick |
@vighneshbirodkar : Yes, the area and sigma have one to one correspondence and I agree it is pretty direct. A case where a user might want |
@ankit-maverick |
True.
If I am not wrong, it's the other way round :)
I agree that this DoG blob detector is not intended to be used inside SIFT, but my point was that the sigma values provide a better interpretation(intuition?) as to what is happening in the scale space. Area, for sure is a better metric when this blob detector is used for application purposes. |
@ankit-maverick |
I like how regionprops returns the info ... with a simple array its easy to confuse which column is which. But before someone from the scikit-image team commented that they generally prefer simple arrays, and in this case there's much fewer properties of the detected objects, so an array is not that bad. |
As I might have mentioned during the last discussion, my preference is to |
Working on it, I'll submit a PR with the change, I've already implemented LoG algorithm, so I'll include that as well.I'll remove area and return just |
Resubmitting #900
As @adonath has mentioned, the last pull request didn't provide significant speed improvements over the Laplacian Of Gaussians (LoG) approach. This computes half the number of Gaussians the last method and is significantly faster than the LoG approach. But the trade-off is accuracy. The esitmated size of the blobs is less accurate than the previous method. LoG approach provides more accurate size estimation ( which I will implement later )
I haven't added an example here. I'll add it in my next PR after this is merged, which will include a example with the
Hubble Deep Field
image.Examples