Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Create a polygon of the real data extents of for 3D surveys #27

Open
EvanBianco opened this issue Jul 8, 2016 · 16 comments
Open

Create a polygon of the real data extents of for 3D surveys #27

EvanBianco opened this issue Jul 8, 2016 · 16 comments

Comments

@EvanBianco
Copy link
Collaborator

Don't need to show a timeslice on the basemap necessarily, but it would be cool to plot a polygon enclosing the actual data extents relative to the inline and crossline rectangular range.

image

@mycarta
Copy link

mycarta commented Jul 9, 2016

This is a possible way with scikit-image, using a time slice:

  1. convert to a binary image with appropriate threshold so that no-data is background and data is foreground
  2. fill in holes in the foreground that may be caused by areas in the data having had intensity (amplitude) very close to the no-data
  3. erode using a very small structuring element
  4. your polygon should be the difference between eroded image and non eroded image

Comments:

  • you may have to use more sophisticated morphological operations for (2); or you could use something like ~np.isnan(slice) or numpy.nonzero(slice)
  • there should be a perimeter option in skimage regionprops that achieves the same as (3)+(4)

@kwinkunks
Copy link
Member

I think the computation would be easier with a bit of trace-by-trace processing. Then we can get rid of the zero-crossings. This should work, even for 8-bit data...

https://github.com/agile-geoscience/seisplot/blob/master/Polygon_around_data_area.ipynb

@djchild
Copy link

djchild commented Jul 14, 2016

There are algorithms to compute the convex hull of a set of points.

@mycarta
Copy link

mycarta commented Jul 14, 2016

@djchild: seismic surveys are concave, have you manage to make the convex hull work with them? I'd be curious, I have been looking for something like that for some time. The best I could do myself was with the workflow I describe above.
PS I just bumped into this promising approach with Shapely today: http://blog.thehumangeo.com/2014/05/12/drawing-boundaries-in-python/

@djchild
Copy link

djchild commented Jul 14, 2016

Good point. It has been over a decade since I worked on that and I don't
recall the details. I do remember that you can speed things up a lot by
discarding most of the traces.

Your suggestion of using Delaunay Triangulation is interesting.
Transforming a gnarly geophysics problem into something that can be solved
with a well known computer science algorithm is often a good approach.

There might be some helpful buzzwords here
http://gis.stackexchange.com/questions/1200/what-are-definition-algorithms-and-practical-solutions-for-concave-hull

On Thu, Jul 14, 2016 at 7:30 AM, Matteo notifications@github.com wrote:

@djchild https://github.com/djchild: seismic surveys are concave, have
you manage to make the convex hull work with them? I'd be curious, I have
been looking for something like that for some time. The best I could do
myself was with the workflow I describe above.
PS I just bumped into this promising approach with Shapely today:
http://blog.thehumangeo.com/2014/05/12/drawing-boundaries-in-python/


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#27 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AA5j3_BQkyRbRFIqehYdBNWQ2eiOMs6wks5qVjnlgaJpZM4JIYPT
.

@kwinkunks
Copy link
Member

kwinkunks commented Jul 14, 2016

I improved the contouring method — extracting the contours as shapely polygons. So now I get this, which I think is pretty good...

image

Still an orthogonal grid, but it's all just coordinates.

It would be easy to test the Delauney hack from here too, but it looks a bit imprecise to me, and I wonder how it would adapt to holes.

@EvanBianco
Copy link
Collaborator Author

EvanBianco commented Jan 5, 2017

I just noticed that Mahotas has had some updates and some improved documentation. There is are a few functions to draw polygons on images. One of them computes the convex hull using the Graham Scan https://en.wikipedia.org/wiki/Graham_scan ...See, http://mahotas.readthedocs.io/en/latest/polygon.html

Requires looping over all traces to get a arrays of all the x and y values for each 'live' trace, but then, I suppose it can be discarded once the polygon is created.

@mycarta
Copy link

mycarta commented Jan 5, 2017

So cool that the Wikipedia link has pseudocode. But, do we NOT want concavities in this case?

@EvanBianco
Copy link
Collaborator Author

@mycarta, yes I think you're right.

@djchild
Copy link

djchild commented Apr 29, 2017 via email

@EvanBianco
Copy link
Collaborator Author

Concaveman looks cool. I'll be checking this out. Thanks @djchild!

@kwinkunks
Copy link
Member

kwinkunks commented Apr 30, 2017 via email

@EvanBianco
Copy link
Collaborator Author

Related (perhaps it is a new feature?), transform the time slices into proper orientation relative to a given coordinate system. An example in matplotlib is here, https://matplotlib.org/2.0.0/examples/api/demo_affine_image.html

@mycarta
Copy link

mycarta commented Nov 8, 2018

If the amplitude value for the background (null traces, holes) is known, I would go back again to suggest a scikit-image workflow. Let's say the value is zero; then a logical cutoff can be applied. Something like:

bg_range= numpy.logical_and(data < -10^-4,  data > 10^-4)
data[bg_range] = 0
data[numpy.logical_not(bg_range)] = 1

after which you should have 1s for live data and 0s elsewhere, including holes. Then you should get a contour for each hole plus the boundary. And contour can be accessed individually, sorted, etcetera. I have some examples here but I am also happy to hack if you send a slice or a few my way. This is my recreational drug of choice.

@kwinkunks
Copy link
Member

kwinkunks commented Nov 9, 2018

@evan Moved to #39

@mycarta I think we solved the outline issue, no? See above. Just needs implementing.

@mycarta
Copy link

mycarta commented Nov 9, 2018

@evan Moved to #39

@mycarta I think we solved the outline issue, no? See above. Just needs implementing.

@kwinkunks my bad, it did look like from your last comment that the holes were still a problem, but re-reading again I realize it is about Concaveman

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

No branches or pull requests

4 participants