ImageManipulator
class is a utility class that can
be used to manipulate images and parts of images.
Euclidean Distance: Given two points, and , in two-dimensional space, you should recall that the Euclidean distance between them is given by:
More generally, given two points and , in n-dimensional space, you should recall that the Euclidean distance is given by:
double
"constant"
named TOLERANCE
that has a value of 55.0.
/** * Determine if two Color objects are similar to each other * * @param a One Color * @param b The other Color * @return true if a and b are similar; false otherwise */ public static boolean areSimilar(Color a, Color b)
This method must compute the Euclidean distance between
a
and b
and compare it to
TOLERANCE
. It must return true
if the distance is less than TOLERANCE
and false
otherwise.
This method must use the int
red, green, and blue components
as the three dimensions in the Euclidean distance. These value can
be obtained using the getRed()
, getGreen()
,
and getBlue()
methods in the Color
class.
/** * Make a deep copy of an image * * @param image The original image * @return The (deep) copy of the image */ public static Color[][] copyImage(Color[][] image)
Copyright 2011