Skip to content

Instantly share code, notes, and snippets.

@pedroortizordep
pedroortizordep / elastic_transform.py
Created July 8, 2018 20:39 — forked from chsasank/elastic_transform.py
Elastic transformation of an image in Python
import numpy as np
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
func createTimeLineEntry(headerText: String, bodyText: String, date: Date) -> CLKComplicationTimelineEntry {
let template = CLKComplicationTemplateModularLargeStandardBody()
let swift = UIImage(named: "swift")
template.headerImageProvider =
CLKImageProvider(onePieceImage: swift!)
template.headerTextProvider = CLKSimpleTextProvider(text: headerText)
template.body1TextProvider = CLKSimpleTextProvider(text: bodyText)
func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
let template = CLKComplicationTemplateModularLargeStandardBody()
let beerGlass = UIImage(named: "beer_glass")
template.headerImageProvider =
CLKImageProvider(onePieceImage: beerGlass!)
template.headerTextProvider = CLKSimpleTextProvider(text: "Beer Festival")
template.body1TextProvider = CLKSimpleTextProvider(text: "Beer Tasting Schedule")
handler(template)
}