Python 3: I am trying to find find all green pixels in an image by traversing all pixels using an np.array, but can’t get around index error

In direct answer to your question, the y axis is given first in numpy arrays, followed by the x axis, so interchange your indices. Less directly, you will find that for loops are very slow in Python and you are generally better off using numpy vectorised operations instead. Also, you will often find it easier … Read more

How to pick good contrast RGB colors programmatically?

There is some information in the Web Content Accessibility Guidelines (WCAG) 2.0 (http://www.w3.org/TR/2008/REC-WCAG20-20081211) Visual contrast: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast Contrast ratio: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef Relative luminance : http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef There’s a good example in this site but he calculate where two colors are enough, not how to get them. To choose a color with good contrast, I’d go with complementary colors: … Read more

Script (or some other means) to convert RGB to CMYK in PDF?

This answer is not for Illustrator, but for ‘some other tool’, namely Ghostscript (download gs871w32.exe or gs871w64.exe). Ghostscript allows you to ‘re-distill’ PDFs (without an intermediate conversion to PostScript, the dreaded ‘refrying’ detour). Try this command: gswin32c.exe ^ -o c:/path/to/output-cmyk.pdf ^ -sDEVICE=pdfwrite ^ -dUseCIEColor ^ -sProcessColorModel=DeviceCMYK ^ -sColorConversionStrategy=CMYK ^ -sColorConversionStrategyForImages=CMYK ^ input-rgb.pdf And if you … Read more