Code
BImage pattaya;
void setup(){
pattaya = loadImage("pattaya.jpg");
size(400, 300);
}
void loop(){
int W = pattaya.width;
int H = pattaya.height;
image (pattaya, 0, 0, W, H);
float brightest = 0.0;
int xPos = 0;
int yPos = 0;
for (int i=0; i<W; i++){
for (int n=0; n<H; n++){
color c = get(i,n);
float R = (c & (255<<16))>>16;
float G = (c & (255<<8))>>8;;
float B = (c & (255));
float findbright = R + G + B;
if(findbright > brightest){
brightest = findbright;
xPos = i;
yPos = n;
}
}
}
noFill();
stroke(195,142,144);
noStroke();
noFill();
// rectMode(CENTER_DIAMETER);
ellipseMode(CENTER_DIAMETER);
float m = millis()/100 ;
float d = (m % 80) + 128;
//float t = (m % 10);
fill(228,93, 107, 150);
ellipse(xPos, yPos, 10, 10);
// rect(xPos, yPos, t, t);
}
050 -- Elementary Image Processing: Finding the Brightest Pixel
Statement:Assignments numbered 05x are due Tuesday November 9th.
Find an attractive image of a sunset with the sun clearly visible. Write a program which computationally searches through the image for the brightest pixel (er... probably the sun!) and labels it with some kind of graphic indicator (e.g. box, target, etc.). Your applet may be any size up to 600x600 pixels, please be sure to set the dimensions accordingly when uploading.
More advanced students are obliged to consider a proper technical and visual solution for handling the case when there is more than one "brightest pixel".