pixelogik / colorcube Goto Github PK
View Code? Open in Web Editor NEWDominant color extraction for iOS, macOS and Python
License: MIT License
Dominant color extraction for iOS, macOS and Python
License: MIT License
Hi,
for the image https://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/NDR_Info_Logo.svg/1280px-NDR_Info_Logo.svg.png I get the following (wrong) output:
[0, 0, 0] [0, 50, 101] [255, 194, 0] [121, 92, 0]
Obviously there are no black pixels whatsoever in this image – it looks like the fully transparent pixels are getting count. How does your program deal with alpha values? Can we teach it to ignore them or – perhaps better – take the alpha value into account for the pixel representation?
CGContextDrawImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
Hello Developer,
Really nice library may say appreciate your work on the algorithm implemented.
I have a query like google Image in Iphone is you Check , if you scroll very fast for the search images grid, the first time you see a background of the most dominent color and then the actual image.
I want to implement the same behaviour, hence Can you please recommend if this can be done in this library or any reference.
I dont want to download an image of 3MB then show the dominent color for the second and then actual image rather it should show the dominent color while loading and then the actual image.
Can you advice.
Give the provided image, I would expect a return of a "bluish" color.
But the first color returned is the dark gray on the side, #7b7573
Is this a bug, or is this the correct return and I am misunderstanding the intent of the algorithm? It definitely seems the case that most images with this little bit of dark gray will end up choosing it. I am aware of the avoidColor/avoidDim, etc... alternatives, but i'm wondering if those "workarounds" should be necessary.
Thanks! and thanks for your code!
code:
UIImage* image = [UIImage imageNamed:@"badDominantColor2.png"];
CCColorCube* colorCube = [[CCColorCube alloc] init];
NSArray* imgColors = [colorCube extractColorsFromImage:image flags:0];
UIColor* dominantColor = imgColors[0];
NSLog(@"color:%@", dominantColor.hexString); // use your favorite hexString category
Hi,
I need to replace the pixel colors of the image by output 4 colors.
Here how do I find a particular pixel belongs to which color segment? What would be the calculation.
Thanks
deshan
For the image https://somafm.com/img3/defcon-400.png, I get the following TypeError
when using ColorCube.py
:
➜ Python git:(master) ✗ python3 ./ColorCube.py /tmp/defcon-400.png
Traceback (most recent call last):
File "./ColorCube.py", line 305, in <module>
colors = cc.get_colors(image)
File "./ColorCube.py", line 126, in get_colors
m = self.find_local_maxima(image)
File "./ColorCube.py", line 152, in find_local_maxima
r = float(p[0])/255.0
TypeError: 'int' object is not subscriptable
Thanks for this great implementation! Could you give a hint how to implement the missing sort-by-brightness functionality in the Python version? Cheers, :M:
Hi, Didn't mean to create an issue for this but wanted to let you know I used this lib in a project I released in the App Store. I really enjoy this lib, it helped make my UI unique. Check it out https://tung.fm
Feel free to close this one :)
cheers 🍻
Can this be put on CocoaPods?
Hi, I was just wondering if there was something relatively simple I could do to increase performance when using small images as input.
I'm not saying that ColorCube isn't performant. But i am calling it many times, and was just wondering if perhaps for small images there is something obvious. Like "oh, you really don't need to do x passes, or this data structure could be smaller, or if your images are that small just do it yourself like this"
Essentially, I am almost exclusively working with 10x10 images and looking for only the first dominant color.
thanks!!
Ole!
I like your algorithm more than any of the existing in-browser tools for color extraction, so I made a javascript port.
Great work on ColorCube! The port would have been a lot harder without your super-clean code. 💞
Hi,
First of all, this is a rad library! Thanks!
I'm finding that whenever I use this particular method, I get an error that crashes the app:
- (NSArray *)extractColorsFromImage:(UIImage *)image flags:(NSUInteger)flags avoidColor:(UIColor*)avoidColor;
This happens avoiding either black or white. The error:
-[UIDeviceRGBColor red]: unrecognized selector sent to instance 0x7f86c8eab8e0
Outside of this small issue, I've found this lib works perfectly.
Hello,
First: Congrats for the work you've done! This is a great feature. I'll only suggest that you could create a CocoaPods for this library... this makes things a lot easier to integrate :)
Thanks.
Hey! using your framework in jailbreak tweaks cause springboard to crash entirely. Any plans on updating it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.