0

I'm developing a python task to generate images using PIL.

Is there any way to change numbers back color to yellow instead of white and keep the rest of the image white as it is ?

Please see images below:

Original Image

Posted Image

Expected result is something like this:

Expected Result

Cracker
  • 916
  • 2
  • 7
  • 16
  • Where is numbers back color? How do you define it? – rplnt Nov 15 '11 at 12:37
  • Well, you can just change color in the selected area then (hardocde the coordinates), check this question: http://stackoverflow.com/questions/765736/using-pil-to-make-all-white-pixels-transparent (see second answer) – rplnt Nov 15 '11 at 12:41
  • @rplnt numbers back color can be static in the code – Cracker Nov 15 '11 at 12:42
  • i tried it before i can change the fore colors, but i cannot figure out how to change the back color – Cracker Nov 15 '11 at 12:44
  • 1
    You'll need to find the bounding box of each element. A connected components algorithm would allow you to find the areas to test for white pixels. If pixel is white, set pixel to (0xff,0xff,0x00) for yellow. – David Poole Nov 16 '11 at 18:04
  • Is the question how to determine the background area, or how to recolor the pixels? Or both? – Mark Ransom Nov 16 '11 at 20:51

0 Answers0