Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo n.º 10
0
def evaluate(image, operation, value):
    operation = enum_lookup(operation, operations)

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

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

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

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