Name That Color — PB CLI tool to find color names (dE00)

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

Name That Color — PB CLI tool to find color names (dE00)

Post by Tristano »

Hi everybody,

I'm, glad to announce that I've just release NTC (Name That Color), a command line utility that accepts color definitions (hex or RGB) as input, and returns the color's name:

Code: Select all

$ ntc #ff4020
Pomegranate
$ ntc 120,80,200 
Fuchsia Blue
You can dowload the source code (PB 5.42) —or a precompiled Window x64 binary— here:

https://github.com/tajmone/name-that-color

The project was inspired by the existing NTC JS project — which exists also as a cool online tool.

Basically, ntc contains a table of 1566 color name/value pairs, and when you look up a color it will compare the color difference of target color and each color in the list, returning either the first exact match, or the name of the color less distant from it.

I've implemented the dE00 (CIE Delta E 2000) algorithm for color comparison. So, for those interested in working with colors, there you have it: a full implementation of dE00 algorithm in PureBASIC!

Possibily, in the future I'll add also a GUI version, and tools to manage the color names lists. But first I'll have to handle the passage to the Unicode-only coming version of PB5.50 — as posted at the link below, I've faced some problems with Unicode mode for this app, in Windows CMD (with batch scripts redirected to files), so I've ultimately decided to compile it in Ascii mode:

http://www.purebasic.fr/english/viewtop ... 8&start=60

Any contributions, feedback and forks are most welcome!
Especially from users testing it on Linux and Mac.
The PureBASIC Archives: FOSS Resources:
User avatar
aaaaaaaargh
User
User
Posts: 55
Joined: Thu Jul 27, 2006 1:24 pm

Re: Name That Color — PB CLI tool to find color names (dE00)

Post by aaaaaaaargh »

Hello,
perhaps its just me, but NTC.PB is referenced in the Project but it's not on github
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Name That Color — PB CLI tool to find color names (dE00)

Post by Lunasole »

Hi, I too cannot build it because of ntc.pb missing
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Name That Color — PB CLI tool to find color names (dE00)

Post by Keya »

Tristano wrote:returning either the first exact match, or the name of the color less distant from it.
if it's not an exact match it'd be cool to see the rgb distance difference also if not too tricky, like "Fuschia+(3,-1,5)", or some other way to tell it's not exact like "~Fuschia"
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

Re: Name That Color — PB CLI tool to find color names (dE00)

Post by Tristano »

I REALLY apologize about the inconvenience!

I did leave out a source file ("NTC.PB") from the GitHub repo — I know it shouldn't, but it happens at late night after closing a work in a rush. Meas culpa!

Also, for some reasons I didn't see the email notifications about new posts on this thread, until know. Very bad on my side!

Anyhow, I'll now have to find a way to fix on GitHub the realease, since the source code is incomplete.

Also, please bear in mind that IT WILL NOT COMPILE WITH PB 5.5+ — it must be compiled in Ascii mode, due to problems with Windows CMD shell handling unicode. Not sure I can fix that since it's a Windows OS problem.
if it's not an exact match it'd be cool to see the rgb distance difference also if not too tricky, like "Fuschia+(3,-1,5)", or some other way to tell it's not exact like "~Fuschia"
I think that having the distance expressed in Delta-E (as it is now) is better since it accounts for human visual-perception — meaning that RGB distances are numerical only, but for some color the human eye perceives less distance, and dE was deviced for this. But, if for any other reasons (ie: merely computational/informatic) this feature is needed, it should be easy to add.

If and when I put my hands back on the code (a lot has to do if I find a way to bring it to work with PB 5.5+) I'll consider adding it.

Thanks and sorry for the trouble caused!
The PureBASIC Archives: FOSS Resources:
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Name That Color — PB CLI tool to find color names (dE00)

Post by Lunasole »

Tristano wrote: Also, please bear in mind that IT WILL NOT COMPILE WITH PB 5.5+ — it must be compiled in Ascii mode, due to problems with Windows CMD shell handling unicode. Not sure I can fix that since it's a Windows OS problem.
Can you describe that problem exactly (or show a small demo with it)? I'm compiling most of my programs to unicode and never seen any problems with command line nor using XP or Win7.

Also thanks for ntc.pb :)
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

Re: Name That Color — PB CLI tool to find color names (dE00)

Post by Tristano »

Hi Lunasole!
Lunasole wrote:
Tristano wrote: Also, please bear in mind that IT WILL NOT COMPILE WITH PB 5.5+ — it must be compiled in Ascii mode, due to problems with Windows CMD shell handling unicode. Not sure I can fix that since it's a Windows OS problem.
Can you describe that problem exactly (or show a small demo with it)? I'm compiling most of my programs to unicode and never seen any problems with command line nor using XP or Win7.

Also thanks for ntc.pb :)
The problem was related to STDERR. NTC uses both STDOUT and STDERR to output its responses, thus allowing users to catch separately results (in the Help you'll find a more detailed explanation of how and why this comes handy). On STDOUT unicode outputted without any problems, but on STDERR it would add a space between each character.

Basically, Windows is handling Unicode as a two-chars representation (always), and for some reasons when outputting to STDERR via PB you get the empty char. So I compiled it in Ascii mode and noticed that the problem dissapeared — and because NTC doesn't employ any non-Ascii chars, I thought I'd leave it that way for now.

I haven't had a chance to test PB 5.5+, and check how console output to STDERR works. Maybe the problem was solved (I did post under "bugs" about it).

Anyhow, if you compile it with PB 5.4* in Unicode, you'll see what the problem was -- you only need to removed the compiler directives that check for Ascii mode compilation; apart from that it will compile and work, except that it will produce those nasty extra whitespaces on STDERR.
The PureBASIC Archives: FOSS Resources:
Post Reply