/usr/share/pyshared/gamera/plugins/edgedetect.py is in python-gamera 3.3.3-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | #
# Copyright (C) 2001-2005 Michael Droettboom and Robert Ferguson
# 2009 Christoph Dalitz
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
"""Edge detectors based on first and second derivatives, and related
post-processing from the VIGRA Computer Vision Library."""
from gamera.plugin import *
import _edgedetect
########################################
# Edge detection methods
class difference_of_exponential_edge_image(PluginFunction):
u"""
EXPERIMENTAL
Detect and mark edges in an edge image using the Shen/Castan
zero-crossing detector.
Uses code from the VIGRA Computer Vision Library (Copyright
1998-2007 by Ullrich K\u00f6the).
*scale*
The scale relates to the value b of the exponential filter.
*gradient_threshold*
Whenever the gradient at a zero crossing is greater than the
given gradient_threshold, an edge point is marked in the
destination image on the darker side of the zero crossing (the
zero crossing occurs between pixels).
*min_edge_length*
Removes all edges shorter than the number of pixels specified
(0 retains all edges). Values near 10 are suggested.
"""
self_type = ImageType([GREYSCALE, GREY16, FLOAT])
args = Args([Real("scale", (0, 1e300), default=0.8),
Real("gradient_threshold", (0, 1e300), default=4.0),
Int("min_edge_length", (0, 32000), default=0)])
return_type = ImageType([GREYSCALE, GREY16, FLOAT])
def __call__(self, scale=0.8, gradient_threshold=4.0, min_edge_length=0):
return _edgedetect.difference_of_exponential_edge_image(
self, scale, gradient_threshold, min_edge_length)
__call__ = staticmethod(__call__)
doc_examples = [(GREYSCALE,)]
class difference_of_exponential_crack_edge_image(PluginFunction):
u"""EXPERIMENTAL
Detect and mark edges in a crack edge image using the
Shen/Castan zero-crossing detector.
Uses code from the VIGRA Computer Vision Library (Copyright
1998-2007 by Ullrich K\u00f6the).
*scale*
The scale relates to the value b of the exponential filter.
*gradient_threshold*
Whenever the gradient at a zero crossing is greater than the
given gradient threshold, an edge point is marked in the
destination image on the darker side of the zero crossing (the
zero crossing occurs between pixels).
*min_edge_length*
Removes all edges shorter than the number of pixels specified
(0 retains all edges). Values near 10 are suggested.
*close_gaps*
Close one pixel wide gaps.
*beautify*
See the VIGRA Docs.
"""
self_type = ImageType([GREYSCALE, GREY16, FLOAT])
args = Args([Real("scale", (0, 1e300), default=0.8),
Real("gradient_threshold", (0, 1e300), default=4.0),
Int("min_edge_length", (0, 32000), default=0),
Check("close_gaps", default=False),
Check("beautify", default=False)])
return_type = ImageType([GREYSCALE, GREY16, FLOAT])
def __call__(self, scale=0.8, gradient_threshold=4.0, min_edge_length=0,
close_gaps=False, beautify=False):
return _edgedetect.difference_of_exponential_crack_edge_image(
self, scale,
gradient_threshold, min_edge_length, close_gaps, beautify)
__call__ = staticmethod(__call__)
doc_examples = [(GREYSCALE,)]
class canny_edge_image(PluginFunction):
u"""EXPERIMENTAL
Detect and mark edges in an edge image using Canny's algorithm.
Uses code from the VIGRA Computer Vision Library (Copyright
1998-2007 by Ullrich K\u00f6the).
*scale*
The scale relates to the value b of the exponential filter.
*gradient_threshold*
This operator first calls cannyEdgelList() to generate an
edgel list for the given image. Than it scans this list and
selects edgels whose strength is above the given
gradient_threshold.
"""
self_type = ImageType([GREYSCALE, GREY16, FLOAT])
args = Args([Real("scale", [0, 1e300], default=0.8),
Real("gradient_threshold", [0, 1e300], default=4.0)])
return_type = ImageType([GREYSCALE, GREY16, FLOAT])
def __call__(self, scale=0.8, gradient_threshold=4.0):
return _edgedetect.canny_edge_image(self, scale, gradient_threshold)
__call__ = staticmethod(__call__)
doc_examples = [(GREYSCALE,)]
class labeled_region_edges(PluginFunction):
"""
Pixels with a label different from one of its neighboring pixels
are marked black in the returned image.
When *mark_both* is ``True``, both edges of the region border are
marked, resulting in a two pixel wide edge.
"""
self_type = ImageType([ONEBIT, GREYSCALE, GREY16, RGB])
args = Args([Check("mark_both", default=False)])
return_type = ImageType([ONEBIT])
author = "Christoph Dalitz"
# wrapper for passing default argument
def __call__(self, mark_both=False):
return _edgedetect.labeled_region_edges(self, mark_both)
__call__ = staticmethod(__call__)
class outline(PluginFunction):
"""
Traces the outline of the image. This result is obtained by
dilating the image and then XOR'ing the result with the original.
"""
self_type = ImageType([ONEBIT])
return_type = ImageType([ONEBIT])
doc_examples = [(ONEBIT,)]
class EdgeDetect(PluginModule):
category = "Edge"
cpp_headers=["edgedetect.hpp"]
functions = [difference_of_exponential_edge_image,
difference_of_exponential_crack_edge_image,
canny_edge_image,
labeled_region_edges,
outline]
author = u"Ullrich K\u00f6the (wrapped by Robert Ferguson)"
url = "http://gamera.sourceforge.net/"
module = EdgeDetect()
|