Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Mycelium extends PApplet{
- PImage img;
- public static void main(String[] args) {
- PApplet.main("Mycelium");
- }
- public void settings(){
- size(400,400);
- }
- public void setup(){
- img = loadImage("picture.png");
- loadPixels();
- //image(img,0,0);
- background(0);
- fill(255);
- getMaxBrightness((int)random(img.width), (int)random(img.height));
- // int bright =
- // for (int i = 0; i < img.height; i++) {
- // for (int j = 0; j < img.width; j++) { // image is an array of pixels, randomly selects pixels to look at, less precise when smaller size (larger zoom) for better fps
- // int pxlen = (i + img.width * j);// 2D array using 1D array of image
- // if()
- // }
- // }
- }
- public void draw(){
- }
- /*public void myc(float x, float y){
- if(x < img.width && x > 0 && y > 0 && y<img.height){
- int pxlen = (x + img.width * y);
- if(red(img.pixels[pixlen+1])>red(im))
- }
- }*/
- public void getMaxBrightness(int a, int b){
- //loadPixels();
- if(a > 1 && a < img.width-1 && b > 1 && b < img.height-1){
- int max = 0;
- /*for (int x = a - 1; x <= a + 1; x++) {
- for (int y = b-1; y <= b+1; y++ ) {
- int pxlen = (x + img.width * y);
- if(red(img.pixels[pxlen])> max){
- max=img.pixels[pxlen];
- }
- }
- }*/
- for (int x = a - 1; x <= a + 1; x++) {
- for (int y = b-1; y <= b+1; y++ ) {
- int pxlen = (x + img.width * y);
- if(red(img.pixels[pxlen]) >= max){
- ellipse(x,y,5,5);
- getMaxBrightness(x,y);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement