Highlighting Extremes

Method to replace the pixel colors in the current picture object that have a color distance less than the passed amount to white or black with the passed replacement color.

public void highlight(double amount, Color replace) {
	Pixel pixel = null;
	// loop through all the pixels in the x direction
	for (int x = 0; x < getWidth(); x++) {
		// loop through all the pixels in the y direction
		for (int y = 0; y < getHeight(); y++) {

		// get the current pixel
			pixel = getPixel(x, y);

			// if the distance from white or black is less than the
			// passed amount use the replace color instead
			if (pixel.colorDistance(Color.white) < amount || pixel.colorDistance(Color.black) < amount) {
				pixel.setColor(replace);
			}	
		}
	}
}

Add this method in Picture class and see results.