Giter Site home page Giter Site logo

tdimagecolors's Introduction

TDImageColors

iOS Library used to detect a number of most used colors in a UIImage.

Installation

Using CocoaPods

pod 'TDImageColors', '~> 0.2'

Traditional method

Just download the source files and drag them into your project.

tdimagecolors's People

Contributors

brynbodayle avatar havock94 avatar timominous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tdimagecolors's Issues

isDistinct problem with B&W photos

Hi, I've noticed a problem in the isDistinct method while comparing colors in a black and white picture.
I was comparing black (RGB 0, 0, 0) and white (RGB 1, 1, 1) and I noticed that the method only compares colors channels by subtracting R and G channels and then R and B channels.

So 0 - 0 < threshold and 1 - 1 < threshold, resulting in white and black colors being considered as not distinct, returning only one color while processing my image.

I then added a control for luminance as well, so if the colors are both in a grey scale AND their luminance is within the threshold, then consider them to be similar, otherwise not.

// Check for grays
if (abs(r - g < 0.03f && fabs(r - b) < 0.03f)) {
if (fabs(rc - gc) < 0.03f && (fabs(rc - bc) < 0.03f)){
//Also check for luminance!!
if(fabs([self luminance] - [color luminance]) < threshold){
return NO;
}else{
return YES;
}
...

After this, the color extraction works for B&W images as well, returning a grey scale palette.
I hope this can help you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.