Created
June 1, 2016 13:44
-
-
Save brendandawes/039d3b90903ef8f01b9baca0c72e7c64 to your computer and use it in GitHub Desktop.
Converts non-white pixels in a black & white image to an ArrayList of PVectors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ArrayList alphaMaskToVectors(String file){ | |
| PImage img = loadImage(file); | |
| ArrayList vectors = new ArrayList(); | |
| for (int i=0; i < img.width; i++) { | |
| for (int j=0; j < img.height; j++) { | |
| color c = img.get(i,j); | |
| if (red(c) != 255 && green(c) != 255 && blue(c) != 255) { | |
| vectors.add(new PVector(i,j)); | |
| } | |
| } | |
| } | |
| return vectors; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment