How to create CMYK halftone Images from a color image?

后端 未结 2 958
说谎
说谎 2020-12-05 09:09

I am working on a project that requires me to separate out each color in a CYMK image and generate a halftone image that will be printed on a special halftone printer. The m

2条回答
  •  青春惊慌失措
    2020-12-05 09:26

    My solution also uses PIL, but relies on the internal dithering method (Floyd-Steinberg) supported internally. Creates artifacts, though, so I am considering rewriting its C code.

        from PIL import Image
    
        im  = Image.open('tree.jpg')             # open RGB image
        cmyk= im.convert('CMYK').split()         # RGB contone RGB to CMYK contone
        c = cmyk[0].convert('1').convert('L')    # and then halftone ('1') each plane
        m = cmyk[1].convert('1').convert('L')    # ...and back to ('L') mode
        y = cmyk[2].convert('1').convert('L')
        k = cmyk[3].convert('1').convert('L')
    
        new_cmyk = Image.merge('CMYK',[c,m,y,k]) # put together all 4 planes
        new_cmyk.save('tree-cmyk.jpg')           # and save to file
    

    The implicit GCR PIL applies can also be expanded with a more generic one, but I have tried to describe a simple solution, where also resolution and sampling are ignored.

提交回复
热议问题