Image processing 在处理过程中,如何在每个图像的每个边缘周围包含一个5像素的彩色间隙?

Image processing 在处理过程中,如何在每个图像的每个边缘周围包含一个5像素的彩色间隙?,image-processing,processing,Image Processing,Processing,我现在正在尝试我的学校项目,我们被要求在每幅图像的每一个边缘制作5像素的彩色间隙 我试着使用line(),stroke()和strokeWeight()函数,但没有成功。我想可能是图像下面的线条,也许我应该让线条与图像重叠?还有别的办法吗 这就是我到目前为止所做的 PImage cat; PImage cat2; PImage cat3; PImage cat4; PImage cat5; PImage cat6; PImage cat7; PImage cat8; color Purple

我现在正在尝试我的学校项目,我们被要求在每幅图像的每一个边缘制作5像素的彩色间隙

我试着使用
line()
stroke()
strokeWeight()
函数,但没有成功。我想可能是图像下面的线条,也许我应该让线条与图像重叠?还有别的办法吗

这就是我到目前为止所做的

PImage cat;
PImage cat2;
PImage cat3;
PImage cat4;
PImage cat5;
PImage cat6;
PImage cat7;
PImage cat8;

color Purple = color(186,85,211);

void setup() {
    // load the image file from the "data" folder
    cat = loadImage("cat.jpg");

    // showing the same 9 images, perfectly arranged as 3-by-3 grid
    size(cat.width + cat.width + cat.width,
      (cat.height + cat.height + cat.height));
}

void draw() {
    //  Gap
    line (0, 0, width*3, 0);
    line (0, height*2, width*3, height*2);
    stroke (186,85,211);
    strokeWeight (5);

    // The background is purple
    background (Purple);

    // purple tint
    tint(186,85,211,126);
    // The image fllows the mouse pointer 
    image(cat, mouseX, mouseY);

    // make a copy of the original
    cat2 = cat.get();
    // No Tint
    tint(255, 255);
    // apply the black & white filter
    cat2.filter (THRESHOLD, 0.7);
    //display the image
    image(cat2, cat2.width, 0);

    // make a copy of the orginal
    cat3 = cat.get();
    // apply the grayscale filter
    cat3.filter(GRAY);
    //display the image
    image(cat3, cat.width*2, 0);

    // make a copy of the original
    cat4 = cat.get();
    // apply the INVERT filter 
    cat4.filter(INVERT);
    //display the image
    image(cat4, 0, cat.height); 

    // original
    image(cat, cat.width*1, cat.height*1);

    // make a copy of the original
    cat5 = cat.get();
    // apply the Posterize filter
    cat5.filter(POSTERIZE,4);
    //display the image
    image(cat5, cat.width*2, cat.height*1);

    // make a copy of the original
    cat6 = cat.get();
    // apply the Blur filter 
    cat6.filter(BLUR,5);
    //display the image
    image(cat6, 0, cat.height*2);

    // make a copy the original
    cat7 = cat.get();
    // make the Eroded filter
    cat7.filter(ERODE);
    //display the image
    image(cat7, cat.width, cat.height*2);

    // make a copy of the original
    cat8 = cat.get();
    // apply the DILATE filter
    cat8.filter(DILATE);
    //display the image
    image(cat8, cat.width*2, cat.height*2);
}
预期结果:

实际结果如下:

不要从结构的角度思考,而要从结果的角度思考:你所展示的也是一个粉红色的
背景()
,图像的间隔基于几个像素填充:

ArrayList<PImage> cats = new ArrayList<Pimage>();

...

void draw() {
  background(155,0,155);
  int padding = 5,
      w = width - 4*padding,
      h = height - 4*padding;
  for (int row=0; row<4; row++) {
    for (int col=0; col<4; col++) {
      int idx = row * 3 + col;
      image(cats.get(idx), col*(w+padding), row*(h+padding), w, h);
    }
  }
}
ArrayList cat=new ArrayList();
...
作废提款(){
背景(1550155);
int padding=5,
w=宽度-4*填充,
h=高度-4*填充;

对于(int row=0;row)您可以添加一个图像来说明您的问题吗?很抱歉,我无法在此处添加图像,因为上传图像至少需要10个声誉,所以我尝试在此处上传图像:猫在同一个图像中,或者有9个图像?您可以添加您迄今为止尝试过的内容(代码),以及代码的结果(另一个屏幕截图)。这是我到目前为止所做的,结果是:猫在同一张图片中,我只是复制了原始图片并使用过滤功能。看起来你先画线,然后画图像,图像会覆盖线。试着按相反的顺序,先画图像,然后画线