Cruisers Forum
 


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 02-01-2010, 09:31   #316
Registered User

Join Date: Jan 2010
Posts: 75
Quote:
Originally Posted by PeteCross View Post

Is there such a function out there?
Or am I barking up the wrong tree?

/Pete
The right link for colour space conversion is : Function Reference (Image Processing Toolbox™)

However another reference gives the following matrix:

X = 0,49000 R + 0,31000 G + 0,20000 B
Y = 0,17697 R + 0,81240 G + 0,01063 B
Z = 0,00000 R + 0,01000 G + 0,99000 B

Construction des primaires CIE-XYZ

Once XYZ are known, you can use "xyz2lab" to get the Lab (or Ciel) values.

Robert.
Robert_1 is offline   Reply With Quote
Old 02-01-2010, 10:29   #317
Registered User

Join Date: Oct 2009
Posts: 50
RGB...?

Quote:
Originally Posted by bdbcat View Post
Will...

I went round and round on this some years ago....
I could never find a colorspace expert that I could communicate with.

Finally concluded that these coefficients are xyL space.

To convert xyL to XYZ
Code:
 
                        X = ( x * L ) / y;
                        Y = L;
                        Z = ( ( ( 1.0 - x ) - y ) * L ) / y;
I don't pretend to understand colorspace conversion, but this is (part of) what opencpn does to get RGB from the CCIE numbers, empirically developed.

Also, I would suggest that folks working on new PLIB data files use alternate names, instead of S52RAZDS.RLE. Might save some confusion later. You can specifiy the PLIB file location in the opencpn config file, and it can be named anything.

Good Luck
Dave
Hi Dave,

This is probably a stupid question, but why doesn't OpenCPN use RGB in the Presentation Library data file in the first place?
Since all this ends up as RGB anyway...

/Pete
PeteCross is offline   Reply With Quote
Old 02-01-2010, 10:36   #318
Registered User
 
manimaul's Avatar

Join Date: Feb 2008
Location: Seattle, WA
Posts: 416
Quote:
Originally Posted by PeteCross View Post
Hi Dave,
This is probably a stupid question, but why doesn't OpenCPN use RGB in the Presentation Library data file in the first place?
Since all this ends up as RGB anyway...
/Pete
hmmm, I was wondering the same thing, i imagine dave is re-using existing open source code (libs52 from openev?)... no sense in reinventing the wheel. thanks for all of your input so far... getting close now
__________________
Marine Navigation for Android:
https://mxmariner.com
manimaul is offline   Reply With Quote
Old 02-01-2010, 11:15   #319
Registered User

Join Date: Oct 2009
Posts: 50
RGB2LAB

Quote:
Originally Posted by manimaul View Post
hmmm, I was wondering the same thing, i imagine dave is re-using existing open source code (libs52 from openev?)... no sense in reinventing the wheel. thanks for all of your input so far... getting close now
OK, Here is the c function for converting RGB to Lab.

void rgb2lab(float R, float G, float B, char &l, char &a, char &b)
{
float x,y,z;

x=0.433910*(R/255)+0.376220*(G/255)+0.189860*(B/255);
y=0.212649*(R/255)+0.715169*(G/255)+0.072182*(B/255);
z=0.017756*(R/255)+0.109478*(G/255)+0.872915*(B/255);

if(y>0.008856)
l=116*pow(y,1.0/3.0);
else
l=903.3*y;

if(x>0.008856)
{
if(y>0.008856)
a=500*(pow(x,1.0/3.0)-pow(y,1.0/3.0));
else
a=500*(pow(x,1.0/3.0)-(7.787*y+16/116));
}
else
{
if(y>0.008856)
a=500*(7.787*x+16/116-pow(y,1.0/3.0));
else
a=500*(7.787*x-7.787*y);
}

if(y>0.008856)
{
if(z>0.008856)
b=200*(pow(y,1.0/3.0)-pow(z,1.0/3.0));
else
b=200*(pow(y,1.0/3.0)-(7.787*z+16/116));
}
else
{
if(z>0.008856)
b=200*(7.787*y+16/116-pow(z,1.0/3.0));
else
b=200*(7.787*y-7.787*z);
}
}
PeteCross is offline   Reply With Quote
Old 02-01-2010, 11:40   #320
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,387
ccie

Code:
This is probably a stupid question, but why doesn't OpenCPN use RGB in the Presentation Library data file in the first place? 
Since all this ends up as RGB anyway...
Answer:
Opencpn persists, against all odds and popular grumbling, to support the IMO/IHO S52 standards for ECDIS display.

www.iho.shom.fr/ECDIS/s52intro.htm

Opencpn is the only low-cost ECS to do so, as far as I can tell. And we shall persist, if only to populate this space in the matrix.

The S52 PLIB is a standardized, extensible format, well documented and understood by ECDIS developers worldwide. As I have said often before, the colors selected by IMO/IHO are not arbitrary. They are intended by design to communicate critical graphical information unambiguously under conditions of high stress and/or restricted visibility. Almost all of the PLIB performance is standardized, so that the deck officers on a Capemax tanker will be quickly at home on a Carnival cruise ship bridge. This is a valuable attribute....

Having said all that, of course, there is no reason not to tweak the PLIB to personal preference, and I support the effort. I imagine that we will have a section on the Website where users can download alternate PLIBs, along with instructions for patching the config file to access that PLIB. Lots more could be done with Feature symbols, line and text styles, etc.

Thanks for listening
Dave
bdbcat is offline   Reply With Quote
Old 02-01-2010, 18:26   #321
Registered User
 
manimaul's Avatar

Join Date: Feb 2008
Location: Seattle, WA
Posts: 416
ok, got it...here is an easy way to convert rgb to Yxy (Y=LRV)

consider line:
CCIE 31LANDA0.4182 0.4220 62.03 brown

0.4182 is x
0.4220 is y
62.03 is Y

so the color is 62.03,0.4182,0.4220 in Yxy... plug those values into

EasyRGB.com and wahlah, you get the color in every available color space

HTTP = #F6C86E
Web safe = #FFCC66
RGB 0-255 = 245.98 200.02 110.02
RGB 0-FF = F5 C8 6E
RGB 0-0.1 = 0.96462 0.78439 0.43144
CMY 0-0.1 = 0.03538 0.21561 0.56856
CMYK % = 0.000 18.684 55.274 3.538
XYZ = 61.471 62.030 23.489
Yxy = 62.030 0.41820 0.42200
CIE-L*ab = 82.929 5.976 50.618
CIE-L*CH = 82.929 50.970 83.267
CIE-L*uv = 82.929 36.230 61.612
HunterLab = 78.759 1.491 37.449

Illuminant = D65
Observer = 2° (1931)


I will post this kiwi raster chart color palette as soon as its finished.
Attached Thumbnails
Click image for larger version

Name:	kiwi.jpg
Views:	227
Size:	67.3 KB
ID:	12346  
__________________
Marine Navigation for Android:
https://mxmariner.com
manimaul is offline   Reply With Quote
Old 03-01-2010, 01:23   #322
Registered User

Join Date: Oct 2009
Posts: 50
Quote:
Originally Posted by manimaul View Post
ok, got it...here is an easy way to convert rgb to Yxy (Y=LRV)
....
....
I will post this kiwi raster chart color palette as soon as its finished.
Manimaul.

What a very nice tool. Well done!

Maybe we could work out a Library data file naming solution, which we could eventually select through the toolbox, with the standard default being the present library data file maintained by Dave.

Would this be something you could live with Dave?
Do you have any more thoughts and comments about this Dave?

/Pete.
PeteCross is offline   Reply With Quote
Old 03-01-2010, 01:45   #323
Registered User
 
idpnd's Avatar

Join Date: Sep 2007
Location: Almería, ES
Boat: Chiquita 46 - Libertalia
Posts: 1,558
Quote:
Originally Posted by bdbcat View Post
Opencpn is the only low-cost ECS to do so, as far as I can tell. And we shall persist, if only to populate this space in the matrix.
Hear, hear!

Quote:
Having said all that, of course, there is no reason not to tweak the PLIB to personal preference, and I support the effort.
The beauty of free source code
__________________
sv Libertalia
idpnd is offline   Reply With Quote
Old 05-01-2010, 19:34   #324
Registered User
 
manimaul's Avatar

Join Date: Feb 2008
Location: Seattle, WA
Posts: 416
Quote:
Originally Posted by PeteCross View Post
Manimaul.
What a very nice tool. Well done!
EasyRGB is a nice tool... unfortunately I made a mistake. CCIE, whatever it is, is not CIE Yxy however close. I was getting slight variations in rendered color inputing Yxy into the CCIE lines of S52RAZDS.RLE.

Back to the drawing board. I need to find an easy way to convert RGB to CCIE.

Will
__________________
Marine Navigation for Android:
https://mxmariner.com
manimaul is offline   Reply With Quote
Old 05-01-2010, 19:58   #325
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,387
RGB->CCIE

Will...

Read the code....Should be possible to build an inverse transform by looking at the code in s52plib.cpp. Search for CCIE.... My code goes from CCIE to RGB to build wxColours.

If I had the time just now I'd hack it out myself

Good Luck
Dave
bdbcat is offline   Reply With Quote
Old 06-01-2010, 04:56   #326
Registered User

Join Date: Oct 2009
Posts: 50
Quote:
Originally Posted by manimaul View Post
EasyRGB is a nice tool... unfortunately I made a mistake. CCIE, whatever it is, is not CIE Yxy however close. I was getting slight variations in rendered color inputing Yxy into the CCIE lines of S52RAZDS.RLE.

Back to the drawing board. I need to find an easy way to convert RGB to CCIE.

Will
Hi Will,

I've looked around the plib code and see that CIEE is xyY format indeed.

This needs 2 convertions. xyY -> XYZ and XYZ -> RGB.

The second conversion XYZ -> RGB differs from PLIB( based on BREP lib)
and EasyRGB.

In our conversion(PLIB), is a tmat array.

There is a commented out tmat array which matches the EasyRGB formular.

If the commented out array is used instead, the colors then seem to match EasyRGB colors.

Unfortunately the original PREB library is no longer maintained and I can find no documentation to explain the values used here.

Perhaps Dave can shine some light on this....

/Pete
PeteCross is offline   Reply With Quote
Old 06-01-2010, 06:20   #327
Registered User
 
manimaul's Avatar

Join Date: Feb 2008
Location: Seattle, WA
Posts: 416
ccie 2 rgb bug?

OK It looks like OpenCPN's rgb rendered values are slightly off then.

Example:
CCIE 31LANDA0.3600 0.4000 49.00 brown

CIE Yxy (49.000 0.36000 0.40000) = RGB (192 188 133)

OpenCPN is rendering LANDA as RGB (201 185 122)

These are close but slightly off.
__________________
Marine Navigation for Android:
https://mxmariner.com
manimaul is offline   Reply With Quote
Old 06-01-2010, 08:01   #328
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,387
CCIE

Will, etc....

We use an alternate translation matrix based on the standard CIE color monitor phosphor values:

Code:
#define  CIE_x_r                0.640            // nominal CRT primaries
#define  CIE_y_r                0.330
#define  CIE_x_g                0.290
#define  CIE_y_g                0.600
#define  CIE_x_b                0.150
#define  CIE_y_b                0.060
#define  CIE_x_w                0.295 //0.3333333333          // monitor white point
#define  CIE_y_w                0.315// 0.3333333333
There is also a gamma factor associated with monitor color factors, determined experimentally.

In adjusting these factors, I made some empirical effort to match the S57/S52 colors produced by a professional ENC: Caris SeeMyDENC. My thinking was the Caris is probably the main worldwide supplier of ECDIS validation tools in the market, so the subjective color representations should be close, or at least recognizable on my uncalibrated LCD monitor.

Aside:
Will, I have lots of S52 documentation as PDF files stored locally. Colors, symbols, standards, etc. I think we need a Reference library section on the website where I can upload this stuff for general availability. Ideas?

Hope this helps.
Dave
bdbcat is offline   Reply With Quote
Old 06-01-2010, 12:01   #329
Registered User

Join Date: Oct 2009
Posts: 50
Quote:
Originally Posted by bdbcat View Post
Will, etc....

We use an alternate translation matrix based on the standard CIE color monitor phosphor values:

Code:
#define  CIE_x_r                0.640            // nominal CRT primaries
#define  CIE_y_r                0.330
#define  CIE_x_g                0.290
#define  CIE_y_g                0.600
#define  CIE_x_b                0.150
#define  CIE_y_b                0.060
#define  CIE_x_w                0.295 //0.3333333333          // monitor white point
#define  CIE_y_w                0.315// 0.3333333333
There is also a gamma factor associated with monitor color factors, determined experimentally.

In adjusting these factors, I made some empirical effort to match the S57/S52 colors produced by a professional ENC: Caris SeeMyDENC. My thinking was the Caris is probably the main worldwide supplier of ECDIS validation tools in the market, so the subjective color representations should be close, or at least recognizable on my uncalibrated LCD monitor.

Aside:
Will, I have lots of S52 documentation as PDF files stored locally. Colors, symbols, standards, etc. I think we need a Reference library section on the website where I can upload this stuff for general availability. Ideas?

Hope this helps.
Dave
Dave and Will,

The seems to me to be a good reason for this code.

Having thought about this, it struck me that both the OpenRGB compatible translation matrix and OpenCPN's matrix would be good to have in the code.
The OpenRGB martrix could be selected by some keyword in the data file,
and without that, the standard translation matrix would be used, as now.

The advantage with this is that the OpenCPN matrix could be tweaked by Dave in the future and not affect any "custom" color schemes, or visa-versa.

/Pete
PeteCross is offline   Reply With Quote
Old 06-01-2010, 17:44   #330
Registered User
 
manimaul's Avatar

Join Date: Feb 2008
Location: Seattle, WA
Posts: 416
Quote:
Originally Posted by bdbcat View Post
Aside:
Will, I have lots of S52 documentation as PDF files stored locally. Colors, symbols, standards, etc. I think we need a Reference library section on the website where I can upload this stuff for general availability. Ideas?

Dave
If we can legally redistribute the pdf data how about pdf2html? The generated html may be able to be simply pasted in.
__________________
Marine Navigation for Android:
https://mxmariner.com
manimaul is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beta Marine Diesel michaelmrc Engines and Propulsion Systems 48 23-03-2016 13:44
Need some technical advice....antennas. Just a Tinch Marine Electronics 15 01-12-2007 15:57
Blue Sea Systems Technical Brief GordMay Electrical: Batteries, Generators & Solar 0 16-03-2007 04:16
technical difficulties witchcraft The Sailor's Confessional 1 30-05-2005 14:09
Dow Corning Technical Manual GordMay The Library 0 12-04-2005 16:25

Advertise Here


All times are GMT -7. The time now is 04:55.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.