I just started using the colorspace package, and converting between RGB and HLS is not working as I expect. In particular, converting RGB(0,0,0) to HLS then back to RGB seems broken: #> as(as(RGB(0, 0, 0), "HLS"), "RGB") R G B [1,] 1 1 0 That is, converting black to HLS then back again produces yellow! Other values I've tried work as expected (i.e., I get the same RGB value out as I put in). Is this a bug in the code, or in my understanding of colour conversions? Kind Regards, Mike
Hi, I cannot reproduce your result: R> as(as(RGB(0, 0, 0), "HLS"), "RGB") R G B [1,] 0 0 0 You probably should provide the output of sessionInfo(). Regards, Pascal On Thu, Mar 13, 2014 at 7:41 AM, Michael Gauland <mikelygee at amuri.net> wrote:> I just started using the colorspace package, and converting between RGB and > HLS is not working as I expect. In particular, converting RGB(0,0,0) to HLS > then back to RGB seems broken: > > #> as(as(RGB(0, 0, 0), "HLS"), "RGB") > R G B > [1,] 1 1 0 > > That is, converting black to HLS then back again produces yellow! > > Other values I've tried work as expected (i.e., I get the same RGB value out > as I put in). > > Is this a bug in the code, or in my understanding of colour conversions? > > Kind Regards, > Mike > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan
On Wed, 12 Mar 2014, Michael Gauland wrote:> I just started using the colorspace package, and converting between RGB and > HLS is not working as I expect. In particular, converting RGB(0,0,0) to HLS > then back to RGB seems broken: > > #> as(as(RGB(0, 0, 0), "HLS"), "RGB") > R G B > [1,] 1 1 0 > > That is, converting black to HLS then back again produces yellow!I can't reproduce this. I get 0,0,0 as expected.> Other values I've tried work as expected (i.e., I get the same RGB value out > as I put in). > > Is this a bug in the code, or in my understanding of colour conversions?Maybe you are using an old version of "colorspace"? For version 1.1-1 (from two years ago, version 1.2-4 is current) the NEWS file says: o Bug fix in HLS_to_RGB conversion for s == 0.> Kind Regards, > Mike > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >