iOS開源:iOSPalette-圖片精確提取主色調算法

billhunter 7年前發布 | 18K 次閱讀 算法 iOS開發 移動開發

1.介紹

Objective-C版本的Google Palette算法在Java.A工具中提取了一個圖像的主要顏色。與傳統的算法相比,iOSPalette可以幫助您提取更有可能成為“主色”的主色。它不是 總是像素數中最大的。

 

2.Why iOS-Palette

1.It always help you to extract the color you want,no the largest in the pixel count.Just like this case:

You can see the 6 TargetMode from the demo screenshot.They are distinguished by different Saturation and Lightness (According to HSL Color Mode).

LIGHT_VIBRANT_MODE (High Lightness , High Saturation)

VIBRANT_MODE(Normal Lightness , High Saturation)

DARK_VIBRANT_MODE(Dark Lightness , High Saturation)

LIGHT_MUTED_MODE(High Lightness , Low Saturation)

MUTED_MODE(Normal Lightness , Low Saturation)

DARK_MUTED_MODE(Dark Lightness , Low Saturation)</pre>

You can get every target mode color thourgh the iOSPalette API if you need!

2.It helps to combine every single RGB Value into a VBox,then calculate the most representational color.

3.How to use iOS-Palette

You can get these simple API in Palette.h and UIImage+Palette.h:

If you need all target mode info, you can use these API in Palette.h and UIImage.Palette.h:

Then you all get the callback with all color infomation you want:

Tips:The recommendColor is the color for the vibrant target.In case of null,It will be replaced by this order:MUTE_MODE------LIGHT_VIRANT_MODE ------LIGHT_MUTE_MODE------DARK_VIBRANT_MODE------DARK_MUTE_MODE.

Absolutely,you can change the order if you want different performance.</pre>

4.Demo

1.Before white background:

2.In the normal illumination:

5.Contact me

if you have any question,you can contact me thourgh the contact infomation below.Or open a issue on Github.I will solve it as soon as possible!Best wishes!

項目主頁:http://www.baiduhome.net/lib/view/home/1496969712318

 

 

 

 本文由用戶 billhunter 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!