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 ) #900
Conversation
I have only had a quick look at the code, but it looks very nice and clean! My recommendation API-wise: use the same convention as with skimage.feature.corner_*. There is certainly not only one blob detector. So we could call this one blob_dog, others would be called blob_xy. |
Thanks for implementing this! Some comments: Clean up whitespace using the I don't have time to try this out today, but will soon. |
@@ -40,4 +41,5 @@ | |||
'CENSURE', | |||
'ORB', | |||
'match_descriptors', | |||
'plot_matches'] | |||
'plot_matches' |
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.
Missing comma, no?
I've left some minor comments inline. I think you should add some more tests, e.g. a test with two blobs in the image (currently there is only one test which has one blob). |
@ahojnnes For eg : LoG can implemented with just two more lines after this @cdeil |
Of course I agree to use my code, it would be nice to have this functionality in scikit-image regularly. Thanks for working on this! The main credits should also go to: http://www.cs.utah.edu/~jfishbau/advimproc/project1/ I just adapted and modified the matlab code he provides on the bottom of the page. I will try to take a closer look at the code and comment within the next days. |
@adonath |
if d <= abs(r1 - r2): | ||
return 1 | ||
|
||
area = (r1 ** 2 * arccos((d ** 2 + r1 ** 2 - r2 ** 2) / (2 * d * r1)) |
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.
Maybe split this formula into multiple statements?
(should improve speed, might increase memory)
Or at least improve formatting to make it more readable?
I've left some very minor comments for typos. Could one of the scikit-image devs please review it and comment on the API? |
return np.array([a for a in array if a[2] > 0]) | ||
|
||
|
||
def get_blobs_dog(image, min_sigma=1, max_sigma=20, num_sigma=50, thresh=1.0, |
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.
What does the dog
stand for?
Please mention this in the docstring and include a reference.
@cdeil @adonath And while testing out I found that only keeping Regarding the point you made about Logarithmic scales. Consider this >>> np.linspace(1,20,10)
array([ 1. , 3.11111111, 5.22222222, 7.33333333,
9.44444444, 11.55555556, 13.66666667, 15.77777778,
17.88888889, 20. ])
>>> np.logspace(math.log(1,10),math.log(20,10),10)
array([ 1. , 1.39495079, 1.94588772, 2.71441762,
3.78647901, 5.2819519 , 7.368063 , 10.27808533,
14.33742329, 20. ]) Using logarithmic scale results in fewer values in the higher ranges. If this were used, the size of larger blobs would be computed with less accuracy. |
Less absolute accuracy, yes. Imagine you have blobs in the size range 10 to 1000 and you want to to have ~ 10 % relative accuracy across that scale range. I think this is a common use case and is where you'd use logarithmic scales ... it's less common I think that you want to measure blobs of both size 10 and 1000 with a fixed absolute accuracy (of say 1). |
Please note that we are now in the situation I have mentioned before, where As for the image, using the original is better (we do not win anything by I am a tad concerned about the runtime here. |
I'll send in a new PR with the JPG image, that's not a problem. @stefanv |
@vighneshbirodkar No, the problem is the growth in the repository size. We'll need to fix it in this PR. |
Ah, it looks like you haven't committed any images yet, so everything is fine. |
Since it's still not 100% clear which Hubble deep field example file will be included in the end, and there are ~ 30 commits in the history with typo / formatting changes, it might be simplest to, at the very end when this is ready, create a new branch off |
@stefanv |
@vighneshbirodkar My mistake. We'll have to rebase as I thought initially. |
I'll wait to hear from the core developers. Whose opinion should I wait for ? |
If I understand correctly, you currently run detection with:
and the default parameters are
I think you can use much fewer scales (and thus faster) if you use |
I put |
I would think |
@cdeil - I'd suggest asking on the astropy mailing list (broader than astropy-dev). Someone may already have one. Also, could you not merge this then substitute the image with AVM later on if needed? |
@stefanv Do you want to include the Hubble deep field file as it is now? Either way is fine with me ... AVM info is not really needed for scikit-image, which just uses pixel coordinates, it's just something that's nice to have for astronomers. |
@cdeil I think the PR is pretty much ready to go, but there is no sense of urgency to push the merge button. We can ask for the AVM info and hear what they say. But how would you include this meta-data? We cannot have FITS files in our data module, since pyfits is an optional dependency. |
AVM info can be included in JPEG or PNG files (see e.g. here). |
Perfect, let's get it then. I need to merge this one manually anyway to remove the old commits. |
I've asked on the astropy mailing list: |
I think we have a winner: @stefanv That is if 570 kB is acceptable, it seems some of the other files in the repo are that large. If it's too large @vighneshbirodkar or I can browse around to find another one. |
I'll crop out a region in the code |
@vighneshbirodkar You already put a lot of work in this PR and it depends on how much effort you still want to put in it, but you might consider implementing the DoG blob detection using a Laplacian-Pyramid, which is much more efficient in terms of speed and memory, especially on larger images. The way it is implemented now it does not differ much (in terms of efficiency and speed) from the LoG approach, it could even be slower. You practically loose the main advantage of the DoG approach. This can be future work, but I think it should be done once the LoG blob detection is available. In my opinion the reason why you would choose the DoG over the LoG approach is because you would choose performance over accuracy of the detections. |
@adonath The SIFT algorithm as far as I know computes successive Gaussians with |
@vighneshbirodkar If you're making a new branch and PR anyways, it might be better to split the Hubble image new data set from the blob detect implementation. |
Resubmitted in #903 |
Example Code
Results
This is my first PR to scikit-image. I would be glad if someone could go through it and suggest improvements
I haven't used Cython before.Could re writing
_blob_overlap
in Cython provide speed improvements ? The main bottle neck in this case is computing the Gaussian Filter.@cdeil , @adonath Please share your thoughts.
LoG will be just minor additions to this. Once this is accepted I'll move onto that and the remaining ones.