Skip to content

Instantly share code, notes, and snippets.

Created February 16, 2017 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3a6b662b80db622a872c701d2b85db68 to your computer and use it in GitHub Desktop.
Save anonymous/3a6b662b80db622a872c701d2b85db68 to your computer and use it in GitHub Desktop.
from scanip_api import *
app = App.GetInstance()
class ThinObjectSmoother(Command):
def __init__(self, dilate, smooth, erode):
Command.__init__(self)
self.doc = App.GetDocument()
self.dilate = dilate
self.smooth = smooth
self.erode = erode
def GetName(self):
return "Special Smooth"
def OnNativeDelete(self):
self.doc.ReleaseCommand(self)
def Do(self):
App.GetDocument().ApplyDilateFilter(Doc.TargetMask, self.dilate, 0)
App.GetDocument().ApplyRecursiveGaussianFilter(Doc.TargetMask, True, Sigma(self.smooth))
App.GetDocument().ApplyErodeFilter(Doc.TargetMask, self.erode, 0)
return True
class ThinObjectSmootherUserAction(UserAction):
def __init__(self, tab, group, name):
UserAction.__init__(self, tab, group, name)
def OnActivated(self):
App.GetDocument().SubmitCommand(ThinObjectSmoother(4, 4.5, 3))
app.AddUserAction(ThinObjectSmootherUserAction(
"Image processing",
"Smoothing",
"Rib smoothing"
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment