Trying to figure out a way to determine the best contrasting color for an areas of a photo. The contrasting color is to be used as the color of some overlaying text.
Using Six Labor ImageSharp, far I've been able to:
- Loaded the image stream into a Sixlabor ImageSharp image:
myImage = Image.Load(imageStream)
- Mutated using Crop to carve out the approx area of where the text should be:
myImage.Mutate(x =>x.Crop(rectangle))
But how do I determine the average/dominate color of this cropped area?
I've seen somewhere that one approach is to resize the cropped area into the size of one pixel. This is easy to do (next step would be: myImage.Mutate(x => x.Resize(1,1))
), but how do I then extract the color of this one pixel then?
As I get this color, I plan on using this approach to calculate the contrasting color.