vrosnet / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 1 forks source link

ImageStatisticsHSL's check for black pixel isn't proper. #62

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
@ Line 169, ImageStatisticsHSL.cs

The correct line should read:

if ((rgb.Red != 0) || (rgb.Green != 0) || (rgb.Blue != 0))

instead of:

if ((hsl.Hue != 0.0) || (hsl.Luminance != 0.0) || (hsl.Saturation != 0.0))

Reason:::
I was upgrading the code to include Hue histogram in the class. This line 
checks whether pixel is black. The calculation inside if block needs to be 
done only if pixel is not black.
Check for Hue!=0.0 is not required (Hue doesn't have any significance for 
the check). Instead, RGB pixel components available in same code section 
could be used.

Original issue reported on code.google.com by piyoo...@gmail.com on 9 May 2008 at 7:48

GoogleCodeExporter commented 8 years ago
I might be wrong saying that here Hue doesn't matter. Pls. confirm. Thanks.

Original comment by piyoo...@gmail.com on 9 May 2008 at 8:51

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 13 May 2008 at 6:33

GoogleCodeExporter commented 8 years ago
In this particular case there is no issue. Since the HSL value is calculated 
from 
RGB, then all non black pixels will form non zero components in HSL. If at 
least one 
HSL component is not equal to zero, then original RGB value represents non 
black 
pixel. In generic case of course I agree – the fact that Saturation or Hue is 
not 
set to zero does not mean that pixel is non black (luminance makes the 
decision).

But, you are right. It is possible to make some tuning. In HSL color space 
black is 
represented by Luminance equal to zero (independent of other components). If 
luminance is not zero, then it is not black and it represents RGB other then 
(0,0,0). So I've simplified the check to:

if ( hsl.Luminance != 0.0 )

Fixed in revision 473. Will be released in AForge.NET 1.6.3.

Original comment by andrew.k...@gmail.com on 13 May 2008 at 7:14