1 of 55

O U R S P O N S O R S

June 11th, 2024

Arrow - upgrade your funcy Kotlin!

Image Processing Done Wrong

​

VIE

2 of 55

Sponsors

2

VIE

3 of 55

Personalvermittlungsfirma mit Fokus auf�IT, Finance und Sales

all people shall advance

VIE

4 of 55

Ticket Raffle

4

15% Discount Code

WWC_KotlinVienna15

VIE

5 of 55

Housekeeping

Slides available @ http://kotlin.wien

​

​

-XenableGarbageCollection

​

5

VIE

6 of 55

KOIN Call for FEEDBACK

  1. Feedback on KOIN
  2. Test the Cloud-Inject Beta

VIE

7 of 55

News

​

  • Kotlinconf Happened�
  • Kotlin Compose Multiplatform�
  • We want to invite prominent speakers directly from Jetbrains ->
  • New Mascot “Kodee”�

​

​

​

​

7

VIE

8 of 55

​

​

​

​

​

Community Interview

​

​

VIE

9 of 55

1 Volunteer

7 easy Questions

Your favourite topic

In German or English

9

VIE

10 of 55

Community Interview

Who are you in one sentence?

How long have you been working with Kotlin?

What are you working on (in Kotlin)?

How is Kotlin used in this project?

Tell us about a Kotlin win.

Tell us about a Kotlin fail.

Any problems/wins using Java Libraries?

Kotlin Frameworks / Features:

  • Arrow
  • AtomicFu
  • Coroutines
  • Exposed
  • Gradle DSL
  • HTML DSL
  • Kodein
  • KotlinX-IO
  • Kotlin Serialization
  • Ktor
  • Ktorm
  • MockK
  • TornadoFx

10

VIE

11 of 55

Upcoming Schedule 2024

​

​

June: Java Vienna "Have you ever considered 24th June� just not writing bugs?" & TBA

June: React Vienna “Demystifying React 24th June� Performance” and “Drawing onto the � Camera with React Native”

August: Kotlin Vienna Stammtisch 20th August

September: Java Vienna Meetup 30th September

October: Kotlin Vienna Beginners Night 1st October

​

​

11

VIE

12 of 55

Ask questions at slido.com

#803 11 99

VIE

13 of 55

Speaker Slides Talk #1

VIE

14 of 55

Markus (Fischer)

THIS IS ME

  • (Coding) Architect @ Senacor since 2017
  • Worked for Germany’s largest banks and insurance companies
  • Projects ranging from new customer onboarding journeys to securities processing workflow systems, on-prem to cloud native and back
  • Mostly backend and web applications (Java, Kotlin, Spring, Kubernetes), �recently a lot of cloud and data platform (Python, Scala, Azure, Databricks)

​

  • Voluntarily chose “Advanced Functional Programming” @ TU �and wrote a Tiny-C Interpreter in Haskell… because academia, you get it.
  • Fell in love Kotlin and Arrow in 2022

Senacor Technologies AG

15 of 55

ARROW

INTRO

“Hey ChatGPT, generate a good presentation on arrow!”

Senacor Technologies AG

16 of 55

ARROW

INTRO

https://arrow-kt.io/

Senacor Technologies AG

17 of 55

ARROW

INTRO

https://arrow-kt.io/

Senacor Technologies AG

18 of 55

AGENDA FOR TONIGHT

  1. Show how amazing Arrow is.
  2. Monetize the hype.

THE PROJECT

https://images.hdqwalls.com/download/red-lamborghini-aventador-new-pn-3840x2400.jpg

✅

🤔

Senacor Technologies AG

19 of 55

AGENDA FOR TONIGHT

  1. Show how amazing Arrow is.
  2. Monetize the hype.

THE PROJECT

https://images.hdqwalls.com/download/red-lamborghini-aventador-new-pn-3840x2400.jpg

✅

🤔

Senacor Technologies AG

20 of 55

AGENDA FOR TONIGHT

THE PROJECT

  1. Show how amazing Arrow is.
  2. Monetize the hype.

https://images.hdqwalls.com/download/red-lamborghini-aventador-new-pn-3840x2400.jpg

✅

🤔

Senacor Technologies AG

21 of 55

THE PLAN

THE PROJECT

  1. Design merch (using AI ofc.)
  2. Build backend for drop shipping our merch
  3. Have some poor FE-dev hack a front end in a framework which gets upgraded every other hour

​

Senacor Technologies AG

22 of 55

THE MERCH

THE PROJECT

COOL.

Senacor Technologies AG

23 of 55

Of course it’s on Github!

THE BACK END

Senacor Technologies AG

24 of 55

SENACOR AT A GLANCE

FACTS & FIGURES

INTERDISCIPLINARY TEAMS

EXCEPTIONALLY SUCCESSFUL

FOCUSED ON DACH REGION

​

​

​

​

​

​

​

​

  • Client projects in the entire DACH region; >50 % of these at globally active companies
  • Flexible setup: Consulting and delivery on-site at the client and / or remote in agile and traditional team setup

Senacor Technologies AG

€ 252m

Revenue (FY 2023)

15-20% p.a.

Growth as a �long-term trend

> 20 YEARS

Experience with �IT transformations

TOP 20

IT consultancies �in Germany1

​

​

​

​

​

​

​

​

​

​

​

​

​

1.000+

Developers, strategists, platform designers and expert consultants

CONSULTING

DEVELOPMENT

1. Lünendonk List 2023

Kundenportfolio (Auszug)

55%

45%

Hamburg

Berlin

Bonn

Leipzig

Lublin

Košice

Wien

Munich

Zurich

Stuttgart

Nuremberg

Eschborn

WE NEED SUPPORT!!

25 of 55

You really [ liked | hated ] this talk and want to let me know…

THE END

Email me

​

Find me on LinkedIn

Talk to me in the break

especially if you want to apply to Senacor… I’ll buy you dinner if you land the job!

Senacor Technologies AG

26 of 55

Speaker Slides Talk #2

VIE

27 of 55

kip

why a horribly unoptimized image processing library

is the best thing I ever made

28 of 55

What?

let‘s take a step back

Topic: Image Processing

  • What is image processing?
  • What is the scope of this talk?
  • Which kinds of abstractions make sense?
  • What is kip?
  • What does its API look like?
  • What can it do? (practical examples)

Meta-Topic: Hobby Programming

  • What is hobby programming?
  • Why is it a good thing?
  • How to choose a hobby project
  • How to finish a project (I don’t know either)
  • Why you should start a hobby project

29 of 55

You‘re gonna see this very often today

This is my test raccoon

(source: https://naturschutzbund.at/neobiota-in-oesterreich/articles/der-waschbaer.html)

30 of 55

The Basics

  • General idea: mapping operation from one image to another
    • (but not like that)
    • Why not?
  • Define a programmatic definition of how to get from A to B
  • One possibility: map every pixel to a new pixel using “some math operation”
  • But what is a pixel?

​

31 of 55

The Smallest Building Block

  • A mixture of three 8-bit unsigned integers representing red, green, blue
    • What about greater bit depths?
    • What about different color models / color spaces?
    • What about alpha?
    • What about different image formats?
  • The answer is simple: Not in the scope of this talk
  • We will focus on the 8-bit RGB model
  • Hex notation: #rrggbb
  • Examples
    • black: #000000, white: #FFFFFF
    • red: #FF0000, green: #00FF00, blue: #0000FF
    • yellow: #FFFF00, magenta: #FF00FF, cyan: #00FFFF
    • random color: #C9E482

​

#624EEE

98 red

(~38%)

78 green

(~31%)

238 blue

(~93%)

32 of 55

The Curve Transformation

 

33 of 55

34 of 55

The Curve Transformation

 

35 of 55

36 of 55

The Curve Transformation

 

37 of 55

The Sigmoid Family

 

https://en.wikipedia.org/wiki/Sigmoid_function

38 of 55

The Possibilities

  • Enough maths!
  • What else can we do?
    • invert
    • brighten
    • saturate
    • desaturate
    • grayscale
    • apply only to a single channel
    • retain only certain pixels
    • blur / smooth
  • That last one is more interesting than the rest

39 of 55

The Blur Filter

  • Usually defined as: Convolution of a square matrix (“kernel”) over the image
  • How boring! (sorry if you like convolutions)
  • Let’s look at the problem differently
  • Basic idea: For every pixel, assign average of surrounding pixels
    • What does “surrounding” mean? -> radius
    • Which pixels precisely? -> shape
    • What does “average” mean? -> weight
  • By configuring these three options, we can customize the blur effect
  • Example:
    • Radius: 25
    • Shape: Star
    • Weight: logarithmic falloff
  • More extreme example:
    • Radius: 50
    • Shape: Cross
    • Weight: linear increase

40 of 55

The Computational Cost

 

41 of 55

The Bloom Effect

  • Algorithm sketch:
    • Create a copy of the original image
    • Retain only pixels which have a maximum color value over threshold
    • Apply a blur filter
    • Add onto the original (unchanged) image
  • Creates a nice “glowing” effect

42 of 55

The Most Important Question

Why?

  • Is this cutting-edge research? No
  • Is this the first time someone made an image processing library? No
  • Is my approach / code better than what’s out there? No
  • Did I have a specific need to develop this project? No… kinda

The point is: I had fun!

In doing something enjoyable, I learnt new things and improved my coding skills

43 of 55

The Project

  • https://github.com/RaphaelTarita/kip
  • “kip” stands for: Kotlin Image Processing
  • Concept:
    • Define functional filters (we’ll come back to this)
    • Provide sensible defaults with the possibility to customize at every point
    • Provide a nice DSL to define a processing pipeline
  • Example: This is what the bloom effect from before looks like in the code

​

val pipeline = buildPipeline {� branch {� left {� step(retainOnly(maxOver(180)))� step(smooth(50, star(), flip(linear(2.5))))� }� combine { a, b -> a.add(b, OverflowHandling.CLAMP) }� }�}��executePipeline(pipeline) {� load { KipImage(ImageIO.read(File(“path/to/myimage.png")), keepSteps = true) }� save { it.saveAllSteps(Path(“path/to/myoutput"), "step", "PNG") }� log { println(it) }�}

44 of 55

The Approach

  • Map pixels taking into account
    • Their color
    • Their location

​

class PixelColor(

val r: UInt,

val g: UInt,

val b: UInt,

val a: Uint

)

(PixelColor) -> PixelColor

45 of 55

The Approach

  • Map pixels taking into account
    • Their color
    • Their location
    • Surrounding pixels

class PixelColor(

val r: UInt,

val g: UInt,

val b: UInt,

val a: Uint

)

(x: Int, y: Int, PixelColor) -> PixelColor

46 of 55

The Approach

  • Map pixels taking into account
    • Their color
    • Their location
    • Surrounding pixels
  • This is considered a “step”, pipeline consists of multiple steps
  • Steps are just functions, you can define your own or use a predefined function

class PixelColor(

val r: UInt,

val g: UInt,

val b: UInt,

val a: Uint

)

PixelAccess.(x: Int, y: Int, PixelColor) -> PixelColor

47 of 55

The Functions

  • kip provides a bunch of higher-order functions
    • Functions that return functions
    • Functions that take functions as parameters
  • Enables composition of functions
  • Example: Build the bloom effect blur filter

linear(2.5)

Returns a function that weighs the center with 250% and falls off to 0% along the radius

(r: Int, max: Int) -> Double

48 of 55

flip(linear(2.5))

The Functions

  • kip provides a bunch of higher-order functions
    • Functions that return functions
    • Functions that take functions as parameters
  • Enables composition of functions
  • Example: Build the bloom effect blur filter

Flip the dynamic weight around (increase to 250% along the radius)

(r: Int, max: Int) -> Double

49 of 55

50, star(), flip(linear(2.5))

The Functions

  • kip provides a bunch of higher-order functions
    • Functions that return functions
    • Functions that take functions as parameters
  • Enables composition of functions
  • Example: Build the bloom effect blur filter

Parameters: radius (number), shape (function), weight (function)

(r: Int, max: Int) -> Double

Int

(r: Int, x: Int, y: Int) -> Boolean

50 of 55

smooth(50, star(), flip(linear(2.5)))

The Functions

  • kip provides a bunch of higher-order functions
    • Functions that return functions
    • Functions that take functions as parameters
  • Enables composition of functions
  • Example: Build the bloom effect blur filter

“smooth” takes one regular and two function parameters and returns a new function

PixelAccess.(x: Int, y: Int, PixelColor) -> PixelColor

51 of 55

step(smooth(50, star(), flip(linear(2.5))))

The Functions

  • kip provides a bunch of higher-order functions
    • Functions that return functions
    • Functions that take functions as parameters
  • Enables composition of functions
  • Example: Build the bloom effect blur filter

“step” is the entrypoint into the pipeline DSL

52 of 55

The DSL

step(retainOnly(maxOver(180)))

branch {�}

left {�}�right {�}

combine { a, b -> ... }

1. Step

2. Branch

3. Left Branch / Right Branch

4. Combine Branches

53 of 55

So…

Is this really the “best thing I ever made”?

What does “best” mean?

It was one of the most fun projects I ever did, so… I guess, yes!

When was the last time you really had fun with a project?

(this is your sign to start a new hobby project)

54 of 55

Thank you for listening!

Questions?

Ideas?

Wanna try something out with kip?

55 of 55

Contact us

If you have any questions or want to get in touch with us, you are more than welcome to do so!

Our contact information:

​

meetup@kotlin.wien

​

55

VIE