-
Notifications
You must be signed in to change notification settings - Fork 68
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
Binary striplog #95
Comments
Typically Also, should these methods enforce that the log is "clean", i.e. no gaps or overlaps? |
Good questions. I had a go in this notebook > https://github.com/agile-geoscience/striplog/blob/master/tutorial/Striplog_with_a_binary_flag.ipynb But yes, these require a strictly True/False value for the primary component... Not sure how it would handle gaps (or what one would want it to do with gaps). I was chatting to Matteo Nicolli about 'greyscale' operations too, but I don't know much about those. Anyway, as far as generalizing beds based on thickness goes, I quite like the result from a binary closing: Where PAM is prune > anneal > merge (the current way to do this) |
Depending on the implementation, greyscale operations might be an easy generalization. Binary erode/dilate/opening/closing are really just special cases (0 & 1 values only) of more general algorithms: # single operations w/ bool
dilated[i] = any(original[neighborhood(i)])
eroded[i] = all(original[neighborhood(i)])
# single operations w/ numeric
dilated[i] = max(original[neighborhood(i)])
eroded[i] = min(original[neighborhood(i)]) I didn't see that plot or an implementation in the notebook, but I'm curious how you did it. Originally I was thinking this would be an operation on intervals (figure out how much the top/base should be shifted, or if the interval should be removed), but another option that would accommodate numeric values would be to convert |
This is a little hacky so I won't PR it, but here's an example: from scipy.ndimage import morphology
for iv in s:
iv.data.update(iv.primary)
def dilate(s, field, height=0.75, step=0.01):
blog, basis, _ = s.to_log(step=step, field='pay', return_meta=True)
blog = morphology.binary_dilation(blog, structure=np.ones(int(height/step)))
return Striplog.from_log(blog, cutoff=0.5, components=comps[::-1], basis=basis)
def erode(s, field, height=0.75, step=0.01):
blog, basis, _ = s.to_log(step=step, field='pay', return_meta=True)
blog = morphology.binary_erosion(blog, structure=np.ones(int(height/step)))
return Striplog.from_log(blog, cutoff=0.5, components=comps[::-1], basis=basis)
dilated = dilate(s, 'pay')
for iv in dilated:
iv.data.update(iv.primary)
eroded = erode(s, 'pay')
for iv in eroded:
iv.data.update(iv.primary)
opened = dilate(eroded, 'pay')
closed = erode(dilated, 'pay') I've double checked that the In any case, I made the structuring element a bit large for emphasis, but here's the plot: |
@rgmyr: brilliant!! |
@rgmyr Ah, sorry, it's only on the Scroll down to Dilate and erode and note that you'd need to be on the bleeding edge I have a bit of nonsense in there to try to make sure we have something that can be interpreted as a binary striplog, but at its heart this is doing the same thing you're doing. I put all the binary ops in one function, since they all basically work in the same way. I started a In this example (below) I computed net:gross as I think the user might want to know how the generalization is potentially changing some statistics... it would be interesting to explore ways to do the generalization in a way that preserves the statistics of the striplog! |
Hmm... I'm not sure about analogous operations with e.g., a constant sum constraint. I might post something on stack exchange and see if anyone has any neat ideas -- maybe there's something clever that can be done with a variable size structuring element, but I'm not really sure how to formulate that as a solvable optimization problem with a unique solution. The only hacky thing I can think of is an iterative approach where we take the output of |
FWIW, I just pushed v0.8.1 with binary morphology. I wanted to avoid depending on If anyone feels like implementing the greyscale operations, especially if it's not too hard w/o |
We do now depend on scipy, so we should implement the gray-level version of this algo. |
Maybe a binary striplog is a special thing? Where the main component property is True or False... then you could allow operations like
dilate
anderode
. (Can't really see how you could allow this on non-binary logs).The text was updated successfully, but these errors were encountered: