Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sin_colors extraction #7

Closed
neeasade opened this issue May 5, 2016 · 25 comments
Closed

sin_colors extraction #7

neeasade opened this issue May 5, 2016 · 25 comments

Comments

@neeasade
Copy link
Member

neeasade commented May 5, 2016

Currently when colors are extracted, if ten aren't found, we fill in the gap up to ten with #000000. This results in a skewed association with dark colors

@venam
Copy link
Member

venam commented May 6, 2016

Maybe we could use different color extractors.

@neeasade
Copy link
Member Author

neeasade commented May 6, 2016

Concur, but suggestions approaching this problem there as well? Repeat colors with highest frequency maybe? An alternative would be to figure a way to dynamically do node count, but it would probably be more work.

@venam
Copy link
Member

venam commented May 6, 2016

@jmbi wrote the go color extracter, maybe he could take a look at that as he has already done his study on the subject.

@neeasade
Copy link
Member Author

neeasade commented May 6, 2016

I have, the issue is still present there(not a fault of the program), only there's no option to print up to a specified number to extract. This makes sense in situations where there aren't x amount of colors to pull (targeting ten as that's the node number we've been associating).

My test input was this image from subtle patterns.

@venam
Copy link
Member

venam commented May 19, 2016

OK, when the colors script is executed on images that have less than 10 colors:

./colors -p -n 10 5zesg.png 
#eeeff0
#eff0f1
#f0f1f2
#f1f2f3
#f2f3f4
#f3f4f5
#f4f5f6

This happens and less than 10 colors are returned.
Maybe we could add a checking for the number of colors actually returned.

Namely extracter.pl should be checked:

    qx#
        ../colors/sin_colors/colors -en 10 $images[$i] |
        ../scripts/convert_hex_to_val_2.pl -s 1 > ../dataset/$nb.images.data
    #;

At the moment it's just doing some shell script magic.
Separating this into multiple steps plus checking will solve it.

@neeasade
Copy link
Member Author

neeasade commented May 19, 2016 via email

@venam
Copy link
Member

venam commented May 19, 2016

Or we could use a random chosen color from the set.
I don't know how either of those will affect everything though.

We can test out the two options, that will need re-extracting the colors from the whole dataset.

@neeasade
Copy link
Member Author

Or we could use a random chosen color from the set.

True, the average colors thing was an attempt to negate favoring one color
over the other.

We can test out the two options, that will need re-extracting the colors
from the whole dataset.

Yeppyepp, this would have needed to happen anyway (In the current set,
pictures without ten colors to pull got the gap filled in with #000000
because that's sin_colors way of handling this).

Pretty sure we're on the same page about options here now, will proceed
experimenting this weekend unless you do first/whatever.

On Thu, May 19, 2016 at 10:32 AM, Patrick Louis notifications@github.com
wrote:

Or we could use a random chosen color from the set.
I don't know how either of those will affect everything though.

We can test out the two options, that will need re-extracting the colors
from the whole dataset.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#7 (comment)

Nathan Isom
Computer Science
Kansas State University

venam pushed a commit that referenced this issue May 20, 2016
In the spirit of this issue:
#7 (comment)

This is still an ongoing test.
@venam
Copy link
Member

venam commented May 24, 2016

https://github.com/nixers-projects/urnn/blob/master/urnn#L78 and
https://github.com/nixers-projects/urnn/blob/master/urnn#L107 also need to take in consideration the case where there aren't 10 colors in the image passed.

Maybe we should write a simple script that handles that.
Only does that:

Takes colors and output 10 colors from them considering all the edge cases.

@venam
Copy link
Member

venam commented Jun 1, 2016

I updated convert_hex_to_val_2.pl to fill up the 10 colors when there are some missing.

I'm thinking that this doesn't make any sense if the colors aren't "ordered" in some way.
Otherwise there is no logic in the inputs.

What do you think?

@neeasade
Copy link
Member Author

neeasade commented Jun 1, 2016

I concur, but as opposed to picking random colors I would prefer to fill
the gap with a single color equal to the average of all colors pulled.

Thanks,
Nathan

On Wed, Jun 1, 2016 at 3:25 AM, Patrick Louis notifications@github.com
wrote:

I update convert_hex_to_val_2.pl to fill up the 10 colors when there are
some missing.

I'm thinking that this doesn't make any sense if the colors aren't
"ordered" in some way.
Otherwise there is no logic in the inputs.

What do you think?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#7 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ADkuRMVe2sRsMZVAswGNXoAVcqB5UagKks5qHUILgaJpZM4IYDvh
.

@venam
Copy link
Member

venam commented Jun 2, 2016

I'm not that good with color theory.
What would an "average color" be?
Do you have an example?

@neeasade
Copy link
Member Author

I was just thinking mathematical average (There's probably a better color
theory way, but.)

So say we had a picture with 3 colors pulled:

#000000
#204020
#ffffff

These equate to:

RGB 0, 0, 0
RGB 0.078, 0.16, 0.078
RGB 1, 1, 1

So, we can average with:

R = (0 + 0.078 + 1)/3 = 0.36 * 255 = 5C
G = (0 + 0.16 + 1)/3 = 0.39 * 255 = 63
B = (0 + 0.078 + 1)/3 = 0.36 * 255 =5C

so the average of the colors is #5C635C.

Thanks,
Nathan

On Wed, Jun 1, 2016 at 11:32 PM, Patrick Louis notifications@github.com
wrote:

I'm not that good with color theory.
What would an "average color" be?
Do you have an example?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#7 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ADkuRHM0NE-ZxdMuH2_U7OTCcQcWQmFoks5qHlzrgaJpZM4IYDvh
.

@venam
Copy link
Member

venam commented Jun 21, 2016

Yeah, this doesn't seem very accurate but we can try.

Let's see what some sample colors will have as complementary colors.

@neeasade
Copy link
Member Author

Leaving a link here for reference later:
http://stackoverflow.com/questions/398224/how-to-mix-colors-naturally-with-c

My goal with this is to neutralize any input beyond limited colors that may
come from a small image.

Thanks,
Nathan

On Tue, Jun 21, 2016 at 3:51 PM, Patrick Louis notifications@github.com
wrote:

Yeah, this doesn't seem very accurate but we can try.

Let's see what some sample colors will have as complementary colors.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#7 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ADkuREVunq2oYYzTvmxar2-yFjAqt9ZMks5qOE7LgaJpZM4IYDvh
.

@venam
Copy link
Member

venam commented Jun 23, 2016

This seems very promising.
https://en.wikipedia.org/wiki/Lab_color_space

This is what we're gonna try implementing.

@venam
Copy link
Member

venam commented Jun 26, 2016

I committed some scripts to convert from one color space to another.

@venam
Copy link
Member

venam commented Jun 27, 2016

I tested with the scripts I wrote for the conversion.

Get the Lab value of the first two colors:
perl xyz_to_Lab.pl $(perl rgb_to_xyz.pl 255 192 203)
perl xyz_to_Lab.pl $(perl rgb_to_xyz.pl 35 168 109)

Calculate their midpoint and run the inverse:
perl xyz_to_rgb.pl $(perl Lab_to_xyz.pl 73.25521690710684 -12.34054291653397 9.779025080442)

HTML          RGB          L.a.b
#FFC0CB -> 255 192 203 -> 80.4714512772271 5.43488940769626 -3.8461673546804
#23A86D -> 35 168 109  -> 66.0389825369866 -30.1159752407642 23.4042175155644


Midpoint is ->  73.25521690710684 -12.34054291653397 9.779025080442
RGB -> 163 180 161, it is #A3B4A1

The visual output is here:
visual output midpoint
The third color is the Lab midpoint and the last one the RGB midpoint.

Now the question arise of which two colors we mix up?
Is it always the first two, then the second and third and so on?

@neeasade
Copy link
Member Author

Now the question arise of which two colors we mix up?

Yes, my impression was we would mix the colors pulled, and then use the result of that mixing for the rest of the empty slots (not continually mix)

@venam
Copy link
Member

venam commented Jun 28, 2016

I don't get it, you want to mix 5 colors together if we only have 5 colors.
Then we would have 6 colors, what do we do with the 4 others?
How would that even work?

@neeasade
Copy link
Member Author

In that example, we would mix the five colors. And then, use the result of that mixing as the value for the other five colors (give them all the same value).

@venam
Copy link
Member

venam commented Jun 29, 2016

I've ran a test.

The results are good.

This is my test image:
test image

It has 10 colors outputed by sin_color:

#14181b
#1f4a4e
#3b302a
#524337
#675948
#807159
#958d6f
#aea783
#cec295
#eed6a1

I took the first 6 and generated the average in the L.a.b colorspace.
Here's the result:
result
The last color is the average of the first 6.

As you can see, you were right, this color can be used to fill the missing ones.
My guess is that it's even more relevant when the image doesn't have 10 colors.

The drawback will be when it's an image that only has 2 colors that totally contrast one another.

Here are more details:

"""
Colors extracted from image: http://pub.iotek.org/p/w7xrjnR.png

#14181b
#1f4a4e
#3b302a
#524337
#675948
#807159
#958d6f
#aea783
#cec295
#eed6a1
"""

print (12.0954800164505+
35.6212096740741+
22.7833360286828+
30.7156518534006+
39.5385110802365+
48.4734500016107)/6.0


print (2.32079677956393 +
2.48100829455616 +
-4.11818111513351+
-7.67516056902925+
-10.1977056824407+
-13.6095909685789)/6.0


print (-1.63506117692257+
-1.75827840918759+
 3.00470067516956+
 5.66935083558926+
 7.56501833231841+
 10.1595992687907)/6.0

# perl xyz_to_rgb.pl $( perl Lab_to_xyz.pl 31.5379397757 -5.13313887684 3.83422158763)      <
#68 73 68
#   #444944
"""
Results: http://pub.iotek.org/p/qzS3wjX.png
"""

@venam
Copy link
Member

venam commented Jun 29, 2016

It's nice to fill the missing colors but the neural network presupposes that the inputs are always in the same order, from darker to lighter.
We have to reorder the colors after generating them.

@venam
Copy link
Member

venam commented Jun 29, 2016

I was also thinking, maybe we can feed the neural network Lab colors instead of RGB colors.

@venam
Copy link
Member

venam commented Jul 10, 2016

I wrote a script called fix_colors.pl it takes a number of colors as inputs and returns exactly 10 colors ordering them by hexadecimal value.
It does that by filling missing colors using the midpoint of the other colors in the Lab colorspace.
I didn't integrate it with the rest of the network.

The scripts to convert from one colorspace to another could be used to feed the network Lab colors instead of RGB but then we'll have to recalibrate the ranges so that we can map Lab to [-1,1].

@venam venam closed this as completed Jul 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants