This file is indexed.

/usr/share/pyshared/gamera/plugins/arithmetic.py is in python-gamera 3.3.2-2.

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
#
#
# Copyright (C) 2001-2005 Ichiro Fujinaga, Michael Droettboom, and Karl MacMillan
#
# 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.
#

"""The image utilities module contains plugins for copy, rotating, resizing,
and computing histograms."""

from gamera.plugin import *
import _arithmetic
import _logical

ARITHMETIC_TYPES = [GREYSCALE, GREY16, FLOAT, RGB, COMPLEX]

class ArithmeticCombine(PluginFunction):
    self_type = ImageType(ARITHMETIC_TYPES)
    args = Args([ImageType(ARITHMETIC_TYPES, 'other'), Check('in_place', default=False)])
    return_type = ImageType(ARITHMETIC_TYPES)
    image_types_must_match = True

class add_images(ArithmeticCombine):
    """
    Adds the corresponding pixels of two images together.

    The two images must be the same type.

    Since it would be difficult to determine what exactly to do if the
    images are a different size, the two images must be the same size.
    Use .subimage on either image to crop appropriately if necessary
    for your specific case.

    *in_place*
      If true, the operation will be performed in-place, changing the
      contents of the current image.
    """
    def __call__(self, other, in_place=False):
       if self.data.pixel_type == ONEBIT:
           return _logical.or_image(self, other, in_place)
       return _arithmetic.add_images(self, other, in_place)
    __call__ = staticmethod(__call__)

    def __doc_example1__(images):
        rgb = images[RGB]
        greyscale = images[GREYSCALE]
        clipped = rgb.clip_image(greyscale)
        return [clipped, greyscale, clipped.add_images(greyscale.to_rgb(), False)]
    doc_examples = [__doc_example1__]

class subtract_images(ArithmeticCombine):
    """
    Adds the pixels of another image from the current image.

    The two images must be the same type.

    Since it would be difficult to determine what exactly to do if the
    images are a different size, the two images must be the same size.
    Use .subimage on either image to crop appropriately if necessary
    for your specific case.

    *in_place*
      If true, the operation will be performed in-place, changing the
      contents of the current image.
    """
    self_type = ImageType(ALL)
    args = Args([ImageType(ALL, 'other'), Check('in_place', default=False)])
    return_type = ImageType(ALL)

    def __call__(self, other, in_place=False):
       return _arithmetic.subtract_images(self, other, in_place)
    __call__ = staticmethod(__call__)

    def __doc_example1__(images):
        rgb = images[RGB]
        greyscale = images[GREYSCALE]
        clipped = rgb.clip_image(greyscale)
        return [clipped, greyscale, clipped.subtract_images(greyscale.to_rgb(), False)]
    doc_examples = [__doc_example1__]

class divide_images(ArithmeticCombine):
    """
    Divides the pixels of the current image by the pixels of another
    image.

    The two images must be the same type.

    Since it would be difficult to determine what exactly to do if the
    images are a different size, the two images must be the same size.
    Use .subimage on either image to crop appropriately if necessary
    for your specific case.

    *in_place*
      If true, the operation will be performed in-place, changing the
      contents of the current image.
    """
    self_type = ImageType([GREYSCALE, GREY16, FLOAT])
    args = Args([ImageType([GREYSCALE, GREY16, FLOAT], 'other'),
                 Check("in_place", default=False)])
    return_type = ImageType([GREYSCALE, GREY16, FLOAT])
                  
    def __call__(self, other, in_place=False):
       return _arithmetic.divide_images(self, other, in_place)
    __call__ = staticmethod(__call__)

class multiply_images(ArithmeticCombine):
    """
    Multiplies the corresponding pixels of two images together.

    The two images must be the same type.

    Since it would be difficult to determine what exactly to do if the
    images are a different size, the two images must be the same size.
    Use .subimage on either image to crop appropriately if necessary
    for your specific case.

    *in_place*
      If true, the operation will be performed in-place, changing the
      contents of the current image.
    """
    def __call__(self, other, in_place=False):
       if self.data.pixel_type == ONEBIT:
           return _logical.and_image(self, other, in_place)
       return _arithmetic.multiply_images(self, other, in_place)
    __call__ = staticmethod(__call__)

class ArithmeticModule(PluginModule):
    cpp_headers=["arithmetic.hpp"]
    category = "Combine/Arithmetic"
    functions = [add_images, subtract_images, multiply_images, divide_images]
    author = "Michael Droettboom"
    url = "http://gamera.sourceforge.net/"
module = ArithmeticModule()
    
del ARITHMETIC_TYPES
del ArithmeticCombine