このウィキの読者になる
更新情報がメールで届きます。
このウィキの読者になる
カテゴリー
最近更新したページ
2011-12-05
2010-02-05
2008-01-31
2007-12-09
2007-11-22
2007-11-04
2007-10-06
2007-05-17
2007-05-13
2007-05-11
2007-05-10
最新コメント
1-14 by awesome things!
117 by stunning seo guys
Processing4 Data by stunning seo guys
送信ボタンの仕組み by stunning seo guys
511 by stunning seo guys
510 by music production software
ProStr by awesome things!
FrontPage by check it out
CSV形式とは by check it out
Menu

Processing7 Image

PImage a;
void setup()
{
a = loadImage("eames.jpg"); size(200,200); noStroke(); background(255); smooth();
}

void draw()
{
float pointillize = 2.0 + (mouseX / (float) width) * 16.0; int x = int(random(a.width)); int y = int(random(a.height)); int loc = x + y*a.width; float r = red(a.pixels[loc]); float g = green(a.pixels[loc]); float b = blue(a.pixels[loc]); fill(r,g,b,126); ellipse(x,y,pointillize,pointillize);
}
size(200, 200);
colorMode(RGB, width);

int[] hist = new int[width];

PImage a;
a = loadImage("cdi01_g.jpg");
image(a, 0, 0);

for (int i=0; i<width; i++) {
for (int j=0; j<height; j++) { hist[int(red(get(i, j)))]++; }
}

float maxval = 0;
for (int i=0; i<width; i++) {
if(hist[i] > maxval) { maxval = hist[i]; }
}

for (int i=0; i<width; i++) {
hist[i] = int(hist[i]/maxval * height);
}

stroke(width);
for (int i=0; i<width; i+=2) {
line(i, height, i, height-hist[i]);
}
PImage a;
int[] aPixels;
int direction = 1;
boolean onetime = true;
float signal;

void setup()
{
size(200, 200); aPixels = new int[width*height]; noFill(); stroke(255); frameRate(30); a = loadImage("ystone08.jpg"); for(int i=0; i<width*height; i++) { aPixels[i] = a.pixels[i]; }
}

void draw()
{
if (signal > width*height-1 || signal < 0) { direction = direction * -1; }

if(mousePressed) { if(mouseY > height-1) { mouseY = height-1; } if(mouseY < 0) { mouseY = 0; } signal = mouseY*width+mouseX; } else { signal += (0.33*direction); } if(keyPressed) { loadPixels(); for (int i=0; i<width*height; i++) { pixels[i] = aPixels[i]; } updatePixels(); rect(signal%width-5, int(signal/width)-5, 10, 10); point(signal%width, int(signal/width)); } else { loadPixels(); for (int i=0; i<width*height; i++) { pixels[i] = aPixels[int(signal)]; } updatePixels(); }
}
PImage a;
boolean onetime = true;
int[] aPixels = new int[200*200];
int direction = 1;

float signal;

void setup()
{
size(200, 200); stroke(255); a = loadImage("florence03.jpg"); for(int i=0; i<width*height; i++) { aPixels[i] = a.pixels[i]; } frameRate(30);
}

void draw()
{
if (signal > width-1 || signal < 0) { direction = direction * -1; }

if(mousePressed) { signal = abs(mouseY%height); } else { signal += (0.3*direction); } if(keyPressed) { loadPixels(); for (int i=0; i<width*height; i++) { pixels[i] = aPixels[i]; } updatePixels(); line(0, signal, width, signal); } else { loadPixels(); for (int i=0; i<width*height; i++) { pixels[i] = aPixels[int((width*int(signal))+(i%width))]; } updatePixels(); }
}
PImage a, b;
boolean once = false;
int[] buffer;
float bufferOffset, newBufferOffset;

void setup()
{
size(200, 200); buffer = new int[width*height]; bufferOffset = newBufferOffset = 0.0; a = loadImage("construct.jpg"); // Load an image into the program b = loadImage("wash.jpg"); // Load an image into the program frameRate(60);
}

void draw()
{
image(a, 0, 0); newBufferOffset = -b.width/2 + (mouseX*2-width/2); float distance = bufferOffset - newBufferOffset; if( abs(distance) > 0.01 ) { bufferOffset -= distance/10.0; bufferOffset = constrain(bufferOffset, -400, 0); } tint(255, 153); image(b, bufferOffset, 20);
}
PImage img;
int w = 80;

void setup() {
size(200, 200); frameRate(30); img = loadImage("end.jpg");
}

void draw() {
// We're only going to process a portion of the image // so let's set the whole image as the background first image(img,0,0); // Where is the small rectangle we will process int xstart = constrain(mouseX-w/2,0,img.width); int ystart = constrain(mouseY-w/2,0,img.height); int xend = constrain(mouseX+w/2,0,img.width); int yend = constrain(mouseY+w/2,0,img.height); int matrixsize = 3; // It's possible to convolve the image with // many different matrices /* float[][] matrix = { { -1, -1, -1 }, { -1, 9, -1 }, { -1, -1, -1 } }; float[][] matrix = { { -2, -2, -2 }, { -2, 9, 0 }, { -1, 0, 0 } }; loadPixels(); // Begin our loop for every pixel for (int x = xstart; x < xend; x++) { for (int y = ystart; y < yend; y++ ) { color c = convolution(x,y,matrix,matrixsize,img); int loc = x + y*img.width; pixels[loc] = c; } } updatePixels();
}

color convolution(int x, int y, float[][] matrix,int matrixsize, PImage img)
{
float rtotal = 0.0; float gtotal = 0.0; float btotal = 0.0; int offset = matrixsize / 2; for (int i = 0; i < matrixsize; i++){ for (int j= 0; j < matrixsize; j++){ // What pixel are we testing int xloc = x+i-offset; int yloc = y+j-offset; int loc = xloc + img.width*yloc; // Make sure we haven't walked off our image, we could do better here loc = constrain(loc,0,img.pixels.length-1); // Calculate the convolution rtotal += (red(img.pixels[loc]) * matrix[i][j]); gtotal += (green(img.pixels[loc]) * matrix[i][j]); btotal += (blue(img.pixels[loc]) * matrix[i][j]); } } // Make sure RGB is within range rtotal = constrain(rtotal,0,255); gtotal = constrain(gtotal,0,255); btotal = constrain(btotal,0,255); // Return the resulting color return color(rtotal,gtotal,btotal);
}
size(200, 200);
PImage a; // Declare variable 'a' of type PImage
a = loadImage("house.jpg"); // Load the images into the program
image(a, 0, 0); // Displays the image from point (0,0)

int[][] output = new int[width/2][height];

int n2 = 3/2;
int m2 = 3/2;
float[][] kernel = { {-1, -1, -1},
{-1, 6, -1}, {-1, -1, -1} };

for(int y=0; y<height; y++) {
for(int x=0; x<width/2; x++) { float sum = 0; for(int k=-n2; k<n2; k++) { for(int j=-m2; j<m2; j++) { // Reflect x-j to not exceed array boundary int xp = x-j; int yp = y-k; if (xp < 0) { xp = xp + width; } else if (x-j >= width) { xp = xp - width; } // Reflect y-k to not exceed array boundary if (yp < 0) { yp = yp + height; } else if (yp >= height) { yp = yp - height; } sum = sum + kernel[j+m2][k+n2] * red(get(xp, yp)); } } output[x][y] = int(sum); }
}

loadPixels();
for(int i=0; i<height; i++) {
for(int j=0; j<width/2; j++) { pixels[i*width + j] = color(output[j][i], output[j][i], output[j][i]); }
}
updatePixels();
2006年11月18日(土) 10:35:46 Modified by ID:hElD8hu5PA




スマートフォン版で見る