加载到我的草图数据文件夹之外的文件夹中(处理中)

Loading in folder outside of my sketch's data folder (processing)

我确定对此有一个非常直接的答案...虽然我不太明白。
在我的加工草图的数据文件夹中,有一个名为test_segments的文件夹。 test_segments 包含一堆图像。
我需要将 test_segments 中的图像加载到我的 PImage 中。
它看起来像这样:http://imgur.com/a/iG3B6
我的代码:

final int len=25;
final float thresh=170;

boolean newDesign=false;
PImage pic;

ArrayList<PImage> imgContainer;
int n=3;

void setup() {  
  size(800, 800, P2D);
  colorMode(RGB, 255);
  background(250, 250, 250);
  rectMode(CENTER);
  //imageMode(CENTER);

  pic=loadImage("hand.jpg");
  pic.resize(width, height);
  color c1 = color(200,25,25);
  color c2 = color(25, 255, 200);  

  imgContainer=new ArrayList<PImage>();
PImage pimg1=loadImage("this is where test_0.png needs to go")
pimg1.resize(50, 50);
imgContainer.add(pimg1);
  noLoop();
  noStroke();
}

void draw() {
  if (newDesign==false) {
    return;
  }

  pic.loadPixels();

  for (int y = 0; y < height; y+=40) {
    for (int x = 0; x < width; x+=40) {
      int index=y*width+x;
      color pixelValue = pic.pixels[index];
      color rgb = pixelValue;
      int r = (rgb >> 16) & 0xFF;  // Faster way of getting red(argb)
      int g = (rgb >> 8) & 0xFF;   // Faster way of getting green(argb)
      int b = rgb & 0xFF;  

//How far is the current color from white
float dista=dist(r,g,b,255,255,255);

//50 is a threshold value allowing close to white being identified as white
//This value needs to be adjusted based on your actual background color
//Next block is processed only if the pixel not white
if(dista>30){    
      float pixelBrightness = brightness(pixelValue); 
      float imgPicked=constrain(pixelBrightness/thresh, 0, n-1);
      image(imgContainer.get((int)imgPicked),x,y);
}
    }
  }
}



void mouseReleased() {
  newDesign=!newDesign;
  redraw();
}  

谢谢!

你应该能够做到:

PImage pimg1 = loadImage("test_segments/test_0.png");

如果这不起作用,请尝试 post 一个 MCVE,就像我们之前谈到的那样。这是一个 MCVE 示例,可以证明您的问题:

PImage pimg1 = loadImage("test_segments/test_0.png");
image(pimg1, 0, 0);

不要忘记准确地包括您期望发生的事情,以及正在发生的事情。祝你好运。