Skip to content
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

Sobel filter should be 2d for images #12

Open
Brow71189 opened this issue Feb 7, 2020 · 5 comments
Open

Sobel filter should be 2d for images #12

Brow71189 opened this issue Feb 7, 2020 · 5 comments

Comments

@Brow71189
Copy link
Collaborator

No description provided.

@cmeyer
Copy link
Collaborator

cmeyer commented Feb 7, 2020

Sobel currently uses numpy.ndimage.sobel. This looks like it applies a 2D filter. What am I missing?

scipy.ndimage.sobel

@Brow71189
Copy link
Collaborator Author

the default for axis is -1 according to the documentation. To me this looks like it is only applying the filter to the last axis of the image.
Tom (who reported this) also said that you only get the filter in one direction. I'm not sure how exactly he would expect the output to look like, but I'll ask him.
Wikipedia also shows and example for how to calculate sobel of 2D images, so maybe we can use this: Sobel operator
I think overall this would be another application for more user configurable options for our built-in processing tools.

@cmeyer
Copy link
Collaborator

cmeyer commented Feb 7, 2020

Here's another useful link:

Stack OverFlow: Applying the Sobel filter using scipy

@cmeyer
Copy link
Collaborator

cmeyer commented Feb 7, 2020

I did some quick experiments with the following code:

dx = scipy.ndimage.sobel(r03.data, 0)
dy = scipy.ndimage.sobel(r03.data, 1)
m = numpy.hypot(dx, dy)
m = m / numpy.max(m)
show(m)

It seems that the 2D Sobel is useful on some data and not other data. I'm thinking that we should give the user a choice as to what dimension to use (x, y, or radially). We should probably also give them a choice of kernel (type, size).

See nion-software/nionswift#322 too.

@tcpekin
Copy link

tcpekin commented Feb 7, 2020

Agree, I think 2D sobel is the most naively useful. Any time you have curved edges I think it is better than the single axis equivalent. Especially since the use case I have seen the most in microscopy is finding edges of circular diffraction disks/spots, the 2D version is definitely better than the rest. Of course the flexibility of being able to choose is the best possibility.

Another option would be to be able to define any kernel that would then be convolved with the image, with some defaults available, but if you do that, you might be better off just scripting the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants