We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I’m using get() to get a section of an image and then draw the section to the same location it was taken from.
For example:
PImage focal1;
void setup() {
size(900, 600);
focal1 = loadImage(“focal1.jpg");
}
void draw() {
PImage newfocal1;
newfocal1 = focal1.get(0, 0, 300, 200);
image(newfocal1, 0, 0);
}
This process is so I can section up the image into a grid.
I’m doing this so I can load in 2 other images and apply the same process to those images so I can click on the section of the first image and have the ability to cycle though to the same section on the second and third image and back to the same section on the first image.
I plan to have quite a lot of cells for each image so declaring multiple versions of :
newfocal1 = focal1.get(0, 0, 300, 200);
image(newfocal1, 0, 0);
would take ages. I’m coming round to the idea that I will need to create a 2D array for getting the sections. But I am currently a bit confused with how I would link this 2D array to the 2D array of the image I need to get sections of.
Any help would be greatly appreciated.
Elliot.
Comments
You can store all of those sections in an ArrayList of PImage instances: >-)
Reflection about using an array is good. See if From several variables to arrays can help.
Note that the array doesn't need to be 2D: see how the pixels[] array represent a 2D image... Depends on what is more fitting your mental model...
"I am currently a bit confused with how I would link this 2D array to the I need to get sections of."
Now, that's me which is confused... What is the "2D array of the image"? You need an array of PImages, independent of the original image, somehow.