private Picture edgeDetector(
Picture picture,int threshold){
for(int row = 0;row < butterflyHeight - 1;row++){
for(int col = 0;col < butterflyWidth - 1;col++){
pix1 = picture.getPixel(col,row);
displayPixel = display.getPixel(col,row);
//First process two adjacent pixels on the
// same row.
pix2 = picture.getPixel(col + 1,row);
//Get and save the color distance between the
// two pixels.
distance = pix1.colorDistance(pix2.getColor());
//Compare the color distance to the threshold
// and set the color of the pixel in the
// display picture accordingly.
if(distance > threshold){
displayPixel.setColor(Color.RED);
}else{
displayPixel.setColor(Color.WHITE);
}//end else
|