Show
Ignore:
Timestamp:
12/16/06 21:44:34 (18 years ago)
Author:
jerome
Message:

Severely optimized color detection code in GC colorspace with
absolutely NO visible change : so probably the whole time is not
passed in my code, or I'm stupid :-)

Location:
pkpgcounter/trunk/pkpgpdls
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/pkpgpdls/inkcoverage.py

    r439 r442  
    4949    if img.mode != "RGB" : 
    5050        img = img.convert("RGB") 
    51     data = img.getdata()     
    5251    cyan = magenta = yellow = black = 0     
    53     for (r, g, b) in data : 
     52    for (r, g, b) in img.getdata() : 
    5453        if r == g == b : 
    5554            black += 255 - r 
     
    6665def getPercentGC(img, nbpix) :         
    6766    """Determines if a page is in grayscale or colour mode.""" 
    68     result = getPercentCMYK(img, nbpix) 
    69     if result["C"] == result["M"] == result["Y"] == 0.0 : 
    70         return { "G" : 100.0, "C" : 0.0 } 
    71     else :     
    72         return { "G" : 0.0, "C" : 100.0 } 
     67    if img.mode != "RGB" : 
     68        img = img.convert("RGB") 
     69    gray = 0 
     70    for (r, g, b) in img.getdata() : 
     71        if not (r == g == b) : 
     72            # optimize : if a single pixel is no gray the whole page is colored. 
     73            return { "G" : 0.0, "C" : 100.0 } 
     74    return { "G" : 100.0, "C" : 0.0 } 
    7375     
    7476def getPercentBW(img, nbpix) : 
  • pkpgcounter/trunk/pkpgpdls/version.py

    r439 r442  
    2323 
    2424 
    25 __version__ = "2.13" 
     25__version__ = "2.14alpha" 
    2626 
    2727__doc__ = """pkpgcounter : a generic Page Description Languages parser."""