SED from Cube code

Made a pull request while I work on this in case you have comments.
Please add a comment here ... what kind of mask does this create?
Does this include all pixels?
Having some pixels included and some not would make a better test, no?