0
$\begingroup$

I use Java and I have some PNG images. I want to put a caption on my images. However I want that: if an image is bright I want to put a black text on image and if an image is dark I want to put a white text on it. How can I detect an image is bright or dark. This should be a fast algorithm and speed is a bit more important than accuracy.

$\endgroup$
4
  • $\begingroup$ If the image varies from light to dark across where your text goes, you'll have problems. Why not do all your text as light text with a dark outline, and then it stands out on any background. Not sure this is a stats question. $\endgroup$
    – Glen_b
    Jan 27, 2014 at 11:44
  • $\begingroup$ should this not be in stackoverflow? as glen_b already said invert the background. Or just use white text with dark edges. as this will always produce a result no matter the background. $\endgroup$ Jan 27, 2014 at 11:45
  • 1
    $\begingroup$ This question appears to be off-topic because it is about obtaining contrasting text, rather than statistics. $\endgroup$
    – Glen_b
    Jan 27, 2014 at 13:25
  • $\begingroup$ An example of the problem with choosing either a light or a dark text without a contrasting outline can be seen here $\endgroup$
    – Glen_b
    Jan 31, 2014 at 2:07

1 Answer 1

2
$\begingroup$

Actually, I don't think you need anything complex. As also stated in comments:

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.