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)
def map(image, lookup, interpolation): # @ReservedAssignment if not interpolation: interpolation = 'average' interpolation = enum_lookup(interpolation, interpolations) c_call(image, 'clut', lookup, interpolation)
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)
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)
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)
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)
def evaluate(image, operation, value): operation = enum_lookup(operation, operations) c_call(image, 'evaluate', operation, value)
def convert_colorspace(image, colorspace): colorspace = enum_lookup(colorspace, colorspaces) c_call(image, ('transform', 'colorspace'), colorspace)
def _set_state(self, key, value, enum=None): if enum: value = enum_lookup(value, enum) c_call(self, ('set', key), value)
def _set_state(self, key, value, enum=None): if enum: value = enum_lookup(value, enum) c_call(self, ("set", key), value)