Hey there,
I don't normally ask for help, so I could be doing this wrong, but what would be the most efficient way to find the most dominant color in an image using it's imageData?
The best I could come up with is going through every pixel and grabbing it's RGB and getting an average? Or maybe compiling a list of RGB values that are similar?
Get Dominant Color from imageData
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Get Dominant Color from imageData
Hi qberty1337
I think the stack in attachment does a part of the job.
It is an adaptation of a Bernd's script "replace white with blue" I named it "GetColorsImages"
The button write a list of the colors RGB and sort it by the last item (the num of occurences)
Best regards
Jean-Marc
I think the stack in attachment does a part of the job.
It is an adaptation of a Bernd's script "replace white with blue" I named it "GetColorsImages"
The button write a list of the colors RGB and sort it by the last item (the num of occurences)
Best regards
Jean-Marc
- Attachments
-
- GetColorsImageLeg24.livecode.zip
- (157.03 KiB) Downloaded 308 times
https://alternatic.ch
-
- Posts: 35
- Joined: Sun Sep 09, 2012 1:09 pm
Re: Get Dominant Color from imageData
Wow, thanks for making a demo stack like that.
The only thing I hate is that it takes soo long for LC to grab those values of a small image like that.
I just wish there was a quicker way to get the most seen colour from an image.
The only thing I hate is that it takes soo long for LC to grab those values of a small image like that.
I just wish there was a quicker way to get the most seen colour from an image.
Re: Get Dominant Color from imageData
Hi,
Resize the image object to make it fit 100x100 px and get the imageData. That should speed it up, although it will be less accurate.
Kind regards,
Mark
Resize the image object to make it fit 100x100 px and get the imageData. That should speed it up, although it will be less accurate.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 35
- Joined: Sun Sep 09, 2012 1:09 pm
Re: Get Dominant Color from imageData
I was thinking of doing that. But if I had a complicated image like Album Cover Art for music files, then derezzing' it would make my dominant colour completely inaccurate. 
