Inverse of average color #1070
Replies: 5 comments
-
I did create this ToColorARGB extension method just now to make it a little more friendly if you want to incorporate it
|
Beta Was this translation helpful? Give feedback.
-
Hmm, is this issue? - I'm finding that the Hue from the mean > MagicColor > ColorHSL is always zero, same with lightness. So my end color is always a varying light gray, not my goal. |
Beta Was this translation helpful? Give feedback.
-
Okay, instead of using the mean, I knew there was color info in the single pixel I resized to, and tried that. It seemed to do the trick, and the final result is as follows. The math part of the invert color I realize could be about any number than 360, but that was what I'd seen in an example on Stackoverflow.
|
Beta Was this translation helpful? Give feedback.
-
Edit: apparently the problem is in my cast of Take the rest of this with a grain of salt. I'm finding the recommended suggestion of getting the average color with image.Resize(1,1) to be wildly inaccurate. For an image like this, (this is the thumbnail) I get yellow. It has yellow, but I wouldn't say it was anywhere close to the average of it. Yellow values in ARGB = 255, 242, 217, 125 This one is considered a dark blue: 255, 34, 54, 157 This one - light green: 255, 185, 241, 126 My code:
And my updated ARGB class:
|
Beta Was this translation helpful? Give feedback.
-
Think I have it all figured out, and my ARGB class handles all the brains of it. The code to compute the average, as before unchanged:
The ARGB class. I find the converting to and from ushort and byte to be tedious but once it works, it works. I tried an Invert(max - value), it does something, but the Inverse of the hue, saturation and lightness is better.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I've come up with the following to inverse the average color of an image. From googling how to with ImageMagick, I saw on StackOverflow with the command line version to resize to 1,1. So I did that, then borrowing from discussion #699, I get the mean. Though in that instance they were looking for brightness. In test, I did get the pixel colors and average them and got the same value as the mean, so I'm guessing its accurate.
Anyway, I then get the HSL, invert the color via what I saw on StackOverflow, then convert back to color. Then from there to a WPF color.
Is this the best method for all of the above?
Beta Was this translation helpful? Give feedback.
All reactions