Image puzzling
in
Programming Questions
•
2 years ago
Hello,
I'm looknig for cutting an image into regularpieces. I figured I could have 2 loops going through the image and extract regular size defined pieces, then save them...
here's the challenge
a 500x500px picture cut in 10x10 pieces
I'm looknig for cutting an image into regularpieces. I figured I could have 2 loops going through the image and extract regular size defined pieces, then save them...
here's the challenge
a 500x500px picture cut in 10x10 pieces
size(500, 500);
background(255);
noStroke();
fill(0);
String ch = "fold";
createOutput(ch+"dummy");
PImage img = loadImage("decoup2.gif");
PImage crop;
for(int i = 0; i < img.width; i += 50) {
for(int j = 0; j < img.height; j += 50) {
crop = img.get( j, j, j+50, i+50); //location in the first round is top left corner, 50 pic large square
crop.save(ch+"/"+"-"+i+"-"+j+".gif");
}
}
cannot figure what's wrong... maybe there's some other and smarter way, with pixel arrays...?
background(255);
noStroke();
fill(0);
String ch = "fold";
createOutput(ch+"dummy");
PImage img = loadImage("decoup2.gif");
PImage crop;
for(int i = 0; i < img.width; i += 50) {
for(int j = 0; j < img.height; j += 50) {
crop = img.get( j, j, j+50, i+50); //location in the first round is top left corner, 50 pic large square
crop.save(ch+"/"+"-"+i+"-"+j+".gif");
}
}
1