Esempio n. 1
0
def overlay(image, other, x, y, composite):
    if not composite:
        composite = composites.over

    composite = enum_lookup(composite, composites)

    c_call(image, 'composite', other, composite, x, y)
Esempio n. 2
0
def map(image, lookup, interpolation):  # @ReservedAssignment
    if not interpolation:
        interpolation = 'average'

    interpolation = enum_lookup(interpolation, interpolations)

    c_call(image, 'clut', lookup, interpolation)
Esempio n. 3
0
def map(image, lookup, interpolation):  # @ReservedAssignment
    if not interpolation:
        interpolation = 'average'

    interpolation = enum_lookup(interpolation, interpolations)

    c_call(image, 'clut', lookup, interpolation)
Esempio n. 4
0
def overlay(image, other, x, y, composite):
    if not composite:
        composite = composites.over

    composite = enum_lookup(composite, composites)

    c_call(image, 'composite', other, composite, x, y)
Esempio n. 5
0
def add_noise(image, attenuate, noise_type):
    if not noise_type:
        noise_type = 'gaussian'

    noise_type = enum_lookup(noise_type, noises)

    c_call(image, 'add_noise', noise_type, attenuate)
Esempio n. 6
0
def add_noise(image, attenuate, noise_type):
    if not noise_type:
        noise_type = 'gaussian'

    noise_type = enum_lookup(noise_type, noises)

    c_call(image, 'add_noise', noise_type, attenuate)
Esempio n. 7
0
def rescale(image, width, height, factor, filter, blur):  # @ReservedAssignment
    if not filter:
        filter = filters.undefined  # @ReservedAssignment

    width, height = _proportionally(image, width, height)

    if not width and not height:
        if not factor:
            msg = 'Either width, height or factor must be provided'
            raise PystaciaException(msg)

        width, height = image.size
        if not hasattr(factor, '__getitem__'):
            factor = (factor, factor)
        width, height = width * factor[0], height * factor[1]

    c_call(image, 'resize', width, height, enum_lookup(filter, filters), blur)
Esempio n. 8
0
def compare(image, other, metric, factory):
    if image.size != other.size:
        return False

    if not metric:
        metric = metrics.absolute_error

    metric = enum_lookup(metric, metrics)

    if not factory:
        factory = Image

    distortion = c_double()

    diff = c_call(image, ('compare', None, 'images'), other, metric,
                  byref(distortion))

    return (factory(diff), distortion.value)
Esempio n. 9
0
def compare(image, other, metric, factory):
    if image.size != other.size:
        return False

    if not metric:
        metric = metrics.absolute_error

    metric = enum_lookup(metric, metrics)

    if not factory:
        factory = Image

    distortion = c_double()

    diff = c_call(image, ('compare', None, 'images'), other,
                  metric, byref(distortion))

    return(factory(diff), distortion.value)
Esempio n. 10
0
def evaluate(image, operation, value):
    operation = enum_lookup(operation, operations)

    c_call(image, 'evaluate', operation, value)
Esempio n. 11
0
def convert_colorspace(image, colorspace):
    colorspace = enum_lookup(colorspace, colorspaces)
    c_call(image, ('transform', 'colorspace'), colorspace)
Esempio n. 12
0
    def _set_state(self, key, value, enum=None):
        if enum:
            value = enum_lookup(value, enum)

        c_call(self, ('set', key), value)
Esempio n. 13
0
def evaluate(image, operation, value):
    operation = enum_lookup(operation, operations)

    c_call(image, 'evaluate', operation, value)
Esempio n. 14
0
def convert_colorspace(image, colorspace):
    colorspace = enum_lookup(colorspace, colorspaces)
    c_call(image, ('transform', 'colorspace'), colorspace)
Esempio n. 15
0
    def _set_state(self, key, value, enum=None):
        if enum:
            value = enum_lookup(value, enum)

        c_call(self, ("set", key), value)