我写了一个处理代码,以前用选择排序对像素进行了排序。我必须上交它,老师说这样要花很长时间,所以我决定将像素亮度分成50的一部分,然后非常粗略地排序。出来的图像还没有完全排序,我真的不知道哪里出了问题。我不必进行完美分类-实际上,这只是要获得一个看起来很酷的图像。希望有人能帮助我,我的意思是可以理解的!提前致谢
PImage img;
PImage two;
PImage sorted;
int j = 0;
int x = j;
int y = x;
int u = y;
int h = u;
int d = 1;
void setup() {
size(736,1051);
img = loadImage("guy.png");
two = loadImage("guy2.png");
background(two);
}
void draw() {
loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int loc = x + y*width;
float r = red(img.pixels[loc]);
float g = …Run Code Online (Sandbox Code Playgroud)