removing applet folders from svn
@@ -1,65 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Blur extends PApplet {
|
||||
public void setup() {/**
|
||||
* Blur.
|
||||
*
|
||||
* Bluring half of an image by processing it through a
|
||||
* low-pass filter.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
PImage a; // Declare variable "a" of type PImage
|
||||
a = loadImage("trees.jpg"); // Load the images into the program
|
||||
|
||||
float v = 1.0f/9.0f;
|
||||
float[][] kernel = { { v, v, v },
|
||||
{ v, v, v },
|
||||
{ v, v, v } };
|
||||
|
||||
size(200, 200);
|
||||
PImage img = loadImage("trees.jpg"); // Load the original image
|
||||
image(a, 0, 0); // Displays the image from point (0,0)
|
||||
img.loadPixels();
|
||||
// Create an opaque image of the same size as the original
|
||||
PImage edgeImg = createImage(img.width, img.height, RGB);
|
||||
// Loop through every pixel in the image.
|
||||
for (int y = 1; y < img.height-1; y++) { // Skip top and bottom edges
|
||||
for (int x = 1; x < img.width-1; x++) { // Skip left and right edges
|
||||
float sum = 0; // Kernel sum for this pixel
|
||||
for (int ky = -1; ky <= 1; ky++) {
|
||||
for (int kx = -1; kx <= 1; kx++) {
|
||||
// Calculate the adjacent pixel for this kernel point
|
||||
int pos = (y + ky)*width + (x + kx);
|
||||
// Image is grayscale, red/green/blue are identical
|
||||
float val = red(img.pixels[pos]);
|
||||
// Multiply adjacent pixels based on the kernel values
|
||||
sum += kernel[ky+1][kx+1] * val;
|
||||
}
|
||||
}
|
||||
// For this pixel in the new image, set the gray value
|
||||
// based on the sum from the kernel
|
||||
edgeImg.pixels[y*img.width + x] = color(sum);
|
||||
}
|
||||
}
|
||||
// State that there are changes to edgeImg.pixels[]
|
||||
edgeImg.updatePixels();
|
||||
image(edgeImg, 100, 0); // Draw the new image
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Blur" });
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* Blur.
|
||||
*
|
||||
* Bluring half of an image by processing it through a
|
||||
* low-pass filter.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
PImage a; // Declare variable "a" of type PImage
|
||||
a = loadImage("trees.jpg"); // Load the images into the program
|
||||
|
||||
float v = 1.0/9.0;
|
||||
float[][] kernel = { { v, v, v },
|
||||
{ v, v, v },
|
||||
{ v, v, v } };
|
||||
|
||||
size(200, 200);
|
||||
PImage img = loadImage("trees.jpg"); // Load the original image
|
||||
image(a, 0, 0); // Displays the image from point (0,0)
|
||||
img.loadPixels();
|
||||
// Create an opaque image of the same size as the original
|
||||
PImage edgeImg = createImage(img.width, img.height, RGB);
|
||||
// Loop through every pixel in the image.
|
||||
for (int y = 1; y < img.height-1; y++) { // Skip top and bottom edges
|
||||
for (int x = 1; x < img.width-1; x++) { // Skip left and right edges
|
||||
float sum = 0; // Kernel sum for this pixel
|
||||
for (int ky = -1; ky <= 1; ky++) {
|
||||
for (int kx = -1; kx <= 1; kx++) {
|
||||
// Calculate the adjacent pixel for this kernel point
|
||||
int pos = (y + ky)*width + (x + kx);
|
||||
// Image is grayscale, red/green/blue are identical
|
||||
float val = red(img.pixels[pos]);
|
||||
// Multiply adjacent pixels based on the kernel values
|
||||
sum += kernel[ky+1][kx+1] * val;
|
||||
}
|
||||
}
|
||||
// For this pixel in the new image, set the gray value
|
||||
// based on the sum from the kernel
|
||||
edgeImg.pixels[y*img.width + x] = color(sum);
|
||||
}
|
||||
}
|
||||
// State that there are changes to edgeImg.pixels[]
|
||||
edgeImg.updatePixels();
|
||||
image(edgeImg, 100, 0); // Draw the new image
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,66 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Brightness extends PApplet {
|
||||
|
||||
/**
|
||||
* Brightness
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Adjusts the brightness of part of the image
|
||||
* Pixels closer to the mouse will appear brighter.
|
||||
*/
|
||||
|
||||
PImage img;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
frameRate(30);
|
||||
img = loadImage("wires.jpg");
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
loadPixels();
|
||||
for (int x = 0; x < img.width; x++) {
|
||||
for (int y = 0; y < img.height; y++ ) {
|
||||
// Calculate the 1D location from a 2D grid
|
||||
int loc = x + y*img.width;
|
||||
// Get the R,G,B values from image
|
||||
float r,g,b;
|
||||
r = red (img.pixels[loc]);
|
||||
//g = green (img.pixels[loc]);
|
||||
//b = blue (img.pixels[loc]);
|
||||
// Calculate an amount to change brightness based on proximity to the mouse
|
||||
float maxdist = 50;//dist(0,0,width,height);
|
||||
float d = dist(x,y,mouseX,mouseY);
|
||||
float adjustbrightness = 255*(maxdist-d)/maxdist;
|
||||
r += adjustbrightness;
|
||||
//g += adjustbrightness;
|
||||
//b += adjustbrightness;
|
||||
// Constrain RGB to make sure they are within 0-255 color range
|
||||
r = constrain(r,0,255);
|
||||
//g = constrain(g,0,255);
|
||||
//b = constrain(b,0,255);
|
||||
// Make a new color and set pixel in the window
|
||||
//color c = color(r,g,b);
|
||||
int c = color(r);
|
||||
pixels[loc] = c;
|
||||
}
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Brightness" });
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* Brightness
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Adjusts the brightness of part of the image
|
||||
* Pixels closer to the mouse will appear brighter.
|
||||
*/
|
||||
|
||||
PImage img;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
frameRate(30);
|
||||
img = loadImage("wires.jpg");
|
||||
}
|
||||
|
||||
void draw() {
|
||||
loadPixels();
|
||||
for (int x = 0; x < img.width; x++) {
|
||||
for (int y = 0; y < img.height; y++ ) {
|
||||
// Calculate the 1D location from a 2D grid
|
||||
int loc = x + y*img.width;
|
||||
// Get the R,G,B values from image
|
||||
float r,g,b;
|
||||
r = red (img.pixels[loc]);
|
||||
//g = green (img.pixels[loc]);
|
||||
//b = blue (img.pixels[loc]);
|
||||
// Calculate an amount to change brightness based on proximity to the mouse
|
||||
float maxdist = 50;//dist(0,0,width,height);
|
||||
float d = dist(x,y,mouseX,mouseY);
|
||||
float adjustbrightness = 255*(maxdist-d)/maxdist;
|
||||
r += adjustbrightness;
|
||||
//g += adjustbrightness;
|
||||
//b += adjustbrightness;
|
||||
// Constrain RGB to make sure they are within 0-255 color range
|
||||
r = constrain(r,0,255);
|
||||
//g = constrain(g,0,255);
|
||||
//b = constrain(b,0,255);
|
||||
// Make a new color and set pixel in the window
|
||||
//color c = color(r,g,b);
|
||||
color c = color(r);
|
||||
pixels[loc] = c;
|
||||
}
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,94 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Convolution extends PApplet {
|
||||
|
||||
/**
|
||||
* Convolution
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Applies a convolution matrix to a portion of the index.
|
||||
* Move mouse to apply filter to different parts of the image.
|
||||
*/
|
||||
|
||||
PImage img;
|
||||
int w = 80;
|
||||
|
||||
// It's possible to convolve the image with
|
||||
// many different matrices
|
||||
|
||||
float[][] matrix = { { -1, -1, -1 },
|
||||
{ -1, 9, -1 },
|
||||
{ -1, -1, -1 } };
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
frameRate(30);
|
||||
img = loadImage("end.jpg");
|
||||
}
|
||||
|
||||
public 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;
|
||||
loadPixels();
|
||||
// Begin our loop for every pixel
|
||||
for (int x = xstart; x < xend; x++) {
|
||||
for (int y = ystart; y < yend; y++ ) {
|
||||
int c = convolution(x,y,matrix,matrixsize,img);
|
||||
int loc = x + y*img.width;
|
||||
pixels[loc] = c;
|
||||
}
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
public int convolution(int x, int y, float[][] matrix,int matrixsize, PImage img)
|
||||
{
|
||||
float rtotal = 0.0f;
|
||||
float gtotal = 0.0f;
|
||||
float btotal = 0.0f;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Convolution" });
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* Convolution
|
||||
* by Daniel Shiffman.
|
||||
*
|
||||
* Applies a convolution matrix to a portion of the index.
|
||||
* Move mouse to apply filter to different parts of the image.
|
||||
*/
|
||||
|
||||
PImage img;
|
||||
int w = 80;
|
||||
|
||||
// It's possible to convolve the image with
|
||||
// many different matrices
|
||||
|
||||
float[][] matrix = { { -1, -1, -1 },
|
||||
{ -1, 9, -1 },
|
||||
{ -1, -1, -1 } };
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,60 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class EdgeDetection extends PApplet {
|
||||
public void setup() {/**
|
||||
* Edge Detection.
|
||||
*
|
||||
* Exposing areas of contrast within an image
|
||||
* by processing it through a high-pass filter.
|
||||
*/
|
||||
|
||||
float[][] kernel = { { -1, -1, -1 },
|
||||
{ -1, 9, -1 },
|
||||
{ -1, -1, -1 } };
|
||||
|
||||
size(200, 200);
|
||||
PImage img = loadImage("house.jpg"); // Load the original image
|
||||
image(img, 0, 0); // Displays the image from point (0,0)
|
||||
img.loadPixels();
|
||||
// Create an opaque image of the same size as the original
|
||||
PImage edgeImg = createImage(img.width, img.height, RGB);
|
||||
// Loop through every pixel in the image.
|
||||
for (int y = 1; y < img.height-1; y++) { // Skip top and bottom edges
|
||||
for (int x = 1; x < img.width-1; x++) { // Skip left and right edges
|
||||
float sum = 0; // Kernel sum for this pixel
|
||||
for (int ky = -1; ky <= 1; ky++) {
|
||||
for (int kx = -1; kx <= 1; kx++) {
|
||||
// Calculate the adjacent pixel for this kernel point
|
||||
int pos = (y + ky)*width + (x + kx);
|
||||
// Image is grayscale, red/green/blue are identical
|
||||
float val = red(img.pixels[pos]);
|
||||
// Multiply adjacent pixels based on the kernel values
|
||||
sum += kernel[ky+1][kx+1] * val;
|
||||
}
|
||||
}
|
||||
// For this pixel in the new image, set the gray value
|
||||
// based on the sum from the kernel
|
||||
edgeImg.pixels[y*img.width + x] = color(sum);
|
||||
}
|
||||
}
|
||||
// State that there are changes to edgeImg.pixels[]
|
||||
edgeImg.updatePixels();
|
||||
image(edgeImg, 100, 0); // Draw the new image
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "EdgeDetection" });
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* Edge Detection.
|
||||
*
|
||||
* Exposing areas of contrast within an image
|
||||
* by processing it through a high-pass filter.
|
||||
*/
|
||||
|
||||
float[][] kernel = { { -1, -1, -1 },
|
||||
{ -1, 9, -1 },
|
||||
{ -1, -1, -1 } };
|
||||
|
||||
size(200, 200);
|
||||
PImage img = loadImage("house.jpg"); // Load the original image
|
||||
image(img, 0, 0); // Displays the image from point (0,0)
|
||||
img.loadPixels();
|
||||
// Create an opaque image of the same size as the original
|
||||
PImage edgeImg = createImage(img.width, img.height, RGB);
|
||||
// Loop through every pixel in the image.
|
||||
for (int y = 1; y < img.height-1; y++) { // Skip top and bottom edges
|
||||
for (int x = 1; x < img.width-1; x++) { // Skip left and right edges
|
||||
float sum = 0; // Kernel sum for this pixel
|
||||
for (int ky = -1; ky <= 1; ky++) {
|
||||
for (int kx = -1; kx <= 1; kx++) {
|
||||
// Calculate the adjacent pixel for this kernel point
|
||||
int pos = (y + ky)*width + (x + kx);
|
||||
// Image is grayscale, red/green/blue are identical
|
||||
float val = red(img.pixels[pos]);
|
||||
// Multiply adjacent pixels based on the kernel values
|
||||
sum += kernel[ky+1][kx+1] * val;
|
||||
}
|
||||
}
|
||||
// For this pixel in the new image, set the gray value
|
||||
// based on the sum from the kernel
|
||||
edgeImg.pixels[y*img.width + x] = color(sum);
|
||||
}
|
||||
}
|
||||
// State that there are changes to edgeImg.pixels[]
|
||||
edgeImg.updatePixels();
|
||||
image(edgeImg, 100, 0); // Draw the new image
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,67 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Histogram extends PApplet {
|
||||
public void setup() {/**
|
||||
* Histogram.
|
||||
*
|
||||
* Calculates the histogram of an image.
|
||||
* A histogram is the frequency distribution
|
||||
* of the gray levels with the number of pure black values
|
||||
* displayed on the left and number of pure white values on the right.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
colorMode(RGB, width);
|
||||
|
||||
int[] hist = new int[width];
|
||||
|
||||
// Load an image from the data directory
|
||||
// Load a different image by modifying the comments
|
||||
PImage a;
|
||||
a = loadImage("cdi01_g.jpg");
|
||||
image(a, 0, 0);
|
||||
|
||||
// Calculate the histogram
|
||||
for (int i=0; i<width; i++) {
|
||||
for (int j=0; j<height; j++) {
|
||||
hist[PApplet.parseInt(red(get(i, j)))]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the largest value in the histogram
|
||||
float maxval = 0;
|
||||
for (int i=0; i<width; i++) {
|
||||
if(hist[i] > maxval) {
|
||||
maxval = hist[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize the histogram to values between 0 and "height"
|
||||
for (int i=0; i<width; i++) {
|
||||
hist[i] = PApplet.parseInt(hist[i]/maxval * height);
|
||||
}
|
||||
|
||||
// Draw half of the histogram (skip every second value)
|
||||
stroke(width);
|
||||
for (int i=0; i<width; i+=2) {
|
||||
line(i, height, i, height-hist[i]);
|
||||
}
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Histogram" });
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* Histogram.
|
||||
*
|
||||
* Calculates the histogram of an image.
|
||||
* A histogram is the frequency distribution
|
||||
* of the gray levels with the number of pure black values
|
||||
* displayed on the left and number of pure white values on the right.
|
||||
*/
|
||||
|
||||
size(200, 200);
|
||||
colorMode(RGB, width);
|
||||
|
||||
int[] hist = new int[width];
|
||||
|
||||
// Load an image from the data directory
|
||||
// Load a different image by modifying the comments
|
||||
PImage a;
|
||||
a = loadImage("cdi01_g.jpg");
|
||||
image(a, 0, 0);
|
||||
|
||||
// Calculate the histogram
|
||||
for (int i=0; i<width; i++) {
|
||||
for (int j=0; j<height; j++) {
|
||||
hist[int(red(get(i, j)))]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the largest value in the histogram
|
||||
float maxval = 0;
|
||||
for (int i=0; i<width; i++) {
|
||||
if(hist[i] > maxval) {
|
||||
maxval = hist[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize the histogram to values between 0 and "height"
|
||||
for (int i=0; i<width; i++) {
|
||||
hist[i] = int(hist[i]/maxval * height);
|
||||
}
|
||||
|
||||
// Draw half of the histogram (skip every second value)
|
||||
stroke(width);
|
||||
for (int i=0; i<width; i+=2) {
|
||||
line(i, height, i, height-hist[i]);
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,73 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class LinearImage extends PApplet {
|
||||
|
||||
/**
|
||||
* Linear Image.
|
||||
*
|
||||
* Click and drag mouse up and down to control the signal.
|
||||
* Press and hold any key to watch the scanning.
|
||||
*/
|
||||
|
||||
PImage a;
|
||||
boolean onetime = true;
|
||||
int[] aPixels = new int[200*200];
|
||||
int direction = 1;
|
||||
|
||||
float signal;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
stroke(255);
|
||||
a = loadImage("florence03.jpg");
|
||||
for(int i=0; i<width*height; i++) {
|
||||
aPixels[i] = a.pixels[i];
|
||||
}
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
if (signal > width-1 || signal < 0) {
|
||||
direction = direction * -1;
|
||||
}
|
||||
|
||||
if(mousePressed) {
|
||||
signal = abs(mouseY%height);
|
||||
} else {
|
||||
signal += (0.3f*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[PApplet.parseInt((width*PApplet.parseInt(signal))+(i%width))];
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "LinearImage" });
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Linear Image.
|
||||
*
|
||||
* Click and drag mouse up and down to control the signal.
|
||||
* Press and hold any key to watch the scanning.
|
||||
*/
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,83 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class PixelArray extends PApplet {
|
||||
|
||||
/**
|
||||
* Pixel Array.
|
||||
*
|
||||
* Click and drag the mouse up and down to control the signal and
|
||||
* press and hold any key to see the current pixel being read.
|
||||
* This program sequentially reads the color of every pixel of an image
|
||||
* and displays this color to fill the window.
|
||||
*/
|
||||
|
||||
PImage a;
|
||||
int[] aPixels;
|
||||
int direction = 1;
|
||||
boolean onetime = true;
|
||||
float signal;
|
||||
|
||||
public 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];
|
||||
}
|
||||
}
|
||||
|
||||
public 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.33f*direction);
|
||||
}
|
||||
|
||||
if(keyPressed) {
|
||||
loadPixels();
|
||||
for (int i=0; i<width*height; i++) {
|
||||
pixels[i] = aPixels[i];
|
||||
}
|
||||
updatePixels();
|
||||
rect(signal%width-5, PApplet.parseInt(signal/width)-5, 10, 10);
|
||||
point(signal%width, PApplet.parseInt(signal/width));
|
||||
} else {
|
||||
loadPixels();
|
||||
for (int i=0; i<width*height; i++) {
|
||||
pixels[i] = aPixels[PApplet.parseInt(signal)];
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "PixelArray" });
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/**
|
||||
* Pixel Array.
|
||||
*
|
||||
* Click and drag the mouse up and down to control the signal and
|
||||
* press and hold any key to see the current pixel being read.
|
||||
* This program sequentially reads the color of every pixel of an image
|
||||
* and displays this color to fill the window.
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |