Extracts 4 main colors from an image: primary, secondary, detail and background.
Swift version: 2.0
-
Grab the files which name begins with "CD" and copy them to your Xcode Swift project.
-
Optional: tweak
CDSettings
variables -
Create color candidates from image:
let colorCandidates = image.getColorCandidates()
Compile with Xcode 7.0.1+
Download or clone the project, open in Xcode, build.
You can drop a new image on the image view and tweak the sliders to find values you like for the thresholds and ratios.
A Playground is also included for demo purposes.
Suggestions and contributions are welcomed!
-
Improve detector accuracy (see comments in
CDColorDetector.swift
) -
Improve resize image method
-
Make a better demo app
-
Make a framework
-
Make it iOS compatible
This started has a translation from Objective-C to Swift of Color Art by Panic Software, from their 2011 blog article.
Then after lots of changes and optimizations (and a few regressions) I added new features like color names and customizable parameters.
I've also made a simple demo app to test the color detection.
This is a programming exercise. I'm not trying to replace Color Art or to mimic Apple's iTunes, but to build upon the idea and progressively create something different.
MIT but you have to refer to Panic's repository somewhere visible.