Exemple #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)
Exemple #2
0
def map(image, lookup, interpolation):  # @ReservedAssignment
    if not interpolation:
        interpolation = 'average'

    interpolation = enum_lookup(interpolation, interpolations)

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

    interpolation = enum_lookup(interpolation, interpolations)

    c_call(image, 'clut', lookup, interpolation)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #10
0
def evaluate(image, operation, value):
    operation = enum_lookup(operation, operations)

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

        c_call(self, ('set', key), value)
Exemple #13
0
def evaluate(image, operation, value):
    operation = enum_lookup(operation, operations)

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

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