I use PIL to write some text to a picture.The text must be seen wery
clearly.
I write the text to different pictures but to the same position. As
pictures maybe different, colour, in the position where I write the
text, is also different.
Is there a way how to set the font colour so that it will be seen very
clearly in the picture?
For example, if the picture is bright ( for example yellow), the font
colour should be dark( e.g. black) and vice versa.
Is there a routine in PIL available that calculates complementary
colour for RGB pixel format?
Can anyone help?
Thanks
L. 4 3722
Johny wrote:
As pictures maybe different, colour, in the position where I
write the text, is also different.
Is there a way how to set the font colour so that it will be seen
very clearly in the picture?
For example, if the picture is bright ( for example yellow), the
font colour should be dark( e.g. black) and vice versa.
Is there a routine in PIL available that calculates complementary
colour for RGB pixel format?
IMHO, this looks weird, especially in complex images. A better
solution is to draw a background box behind the text that has the
image colors, butt low contrast (or saturation, or whatever).
Can anyone help?
....
Regards,
Björn
--
BOFH excuse #405:
Sysadmins unavailable because they are in a meeting talking about
why they are unavailable so much.
Johny wrote:
I use PIL to write some text to a picture.The text must be seen wery
clearly.
I write the text to different pictures but to the same position. As
pictures maybe different, colour, in the position where I write the
text, is also different.
Is there a way how to set the font colour so that it will be seen very
clearly in the picture?
For example, if the picture is bright ( for example yellow), the font
colour should be dark( e.g. black) and vice versa.
Is there a routine in PIL available that calculates complementary
colour for RGB pixel format?
Can anyone help?
Thanks
L.
Don't you just xor with black?
On Thu, 26 Apr 2007 21:17:42 -0700, James Stroud wrote:
Johny wrote:
> I use PIL to write some text to a picture.The text must be seen wery clearly. I write the text to different pictures but to the same position. As pictures maybe different, colour, in the position where I write the text, is also different. Is there a way how to set the font colour so that it will be seen very clearly in the picture? For example, if the picture is bright ( for example yellow), the font colour should be dark( e.g. black) and vice versa. Is there a routine in PIL available that calculates complementary colour for RGB pixel format? Can anyone help? Thanks L.
Don't you just xor with black?
I shouldn't think so... I always forget if black is all ones or all
zeroes, so I checked here: http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html
>>black = 0x000000 # RGB colours white = 0xffffff black^black == white
False
>>white^black == black
False
Maybe you meant xor with white?
But even so, I gather that the Original Poster is asking for something
slightly different -- despite his mention of complimentary colours. (Or
maybe I'm just reading too much into it?)
I think he's just looking for one colour which has high contrast over a
bunch of pixels in an image. I don't think that can be done, in general:
it seems to me he's assuming that all the pixels in the area he wants
to overlay text on are "nearly" the same colour.
I think that a better solution is to draw a box around the area you
want to write text into. The box should have a contrasting frame:
say, a thin white border followed by a thin black border just inside it:
either the white or the black will contrast with the background, no matter
what colour(s) the background is, since no area can be both black and
white in the same place. Then fill the frame with white, and draw black
text inside it. Nice high contrast.
That is probably the most readable method of placing text over an image.
--
Steven D'Aprano
Steven D'Aprano a écrit :
I shouldn't think so... I always forget if black is all ones or all
zeroes, so I checked here: http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html
For this I use the mnemotechnics idea of "chromatic coil"[*], when
there are *all* colors turning it appear to be *white*. And *no* color
is then *black*.
[*] Babelfish translation for french "roue chromatique" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dom |
last post by:
can someone please help me display text in the console
cout << "Testing";
in a different colour to the default one
|
by: Dj Frenzy |
last post by:
Hi, I know how to use javascript to change a background image to
another background image, and how to change a background colour to
another background colour. Is there a way to change an image to a
backgound colour?
I have a table with a background that has a picture. When the user
hovers over the picture I want the background to change to the
background colour of the rest of the page, as if to make the picture
disappear.
|
by: Mark Ingram |
last post by:
Hi, ive got an imagine in a PictureBox, and would like to get the colour
of the pixel when the mouse is over the control. From what ive (briefly)
seen, there is no way to do this directly in C# and requires you to use
GetPixel from the Win API?
Is this correct? Any other better ways of doing this?
Thanks,
|
by: R. MacDonald |
last post by:
Hello, Group,
If drawing on a control, it would be desirable to select a colour that
significantly differs from the control's background colour. Is there a
standard (or preferred) way to programmatically select a complementary
color at run time?
Thanks in advance for any suggestions.
Cheers,
|
by: Pulzar |
last post by:
Hi there,
I want to show a simple image on a web page, and allow the viewer to
select and change one of the colours used in the image, and immediately
preview the result. I'd like to keep the image processing away from the
server to make the colour selection/preview process quicker, and I also
don't want to pre-generate all possible images as there are too many
colours that can be selected.
Does JS (or any JS libraries) provide image...
| |
by: Johny |
last post by:
I use PIL to write some text to a picture.The text must be seen wery
clearly.
I write the text to different pictures but to the same position. As
pictures maybe different, colour, in the position where I write the
text, is also different.
Is there a way how to set the font colour so that it will be seen very
clearly in the picture?
For example, if the picture is bright ( for example yellow), the font
colour should be dark( e.g. black)...
|
by: beertje |
last post by:
This has me a bit stumped...
I'm trying to extract pictures from a file. So far I'm successfully
retrieved the header and what I think is the colour for each pixel.
Here's the description:
"""
3) The picture data format:
The color information is 15 bit data stored in 16 bit. This means the
most
|
by: kuratkull |
last post by:
Hello,
I haven't asked If I wasn't really confused :)
OK, so I am just beginning SDL programming in C, and I was running fine, until I tried getting a pixel colour.
Basically, I am trying to run the code from this page:
http://www.libsdl.org/cgi/docwiki.cgi/Pixel_20Access
This is the cut down version of my code:
|
by: ofiras |
last post by:
In bitmap, how can I find the nearest pixel (pixel
1) to a specific pixel (pixel 2) that has different color from pixel
2? Or how can I find a pixel in a specific distance from pixel 2 (like
a circle that pixel 2 is his center, and I'm looking for a pixel that
has different color that pixel 2)?
(I'm trying to do a voronoi diagram maker, so I need to search for the
nearest colored pixel in my bitmap for every pixel that is not colored...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |