please help me calculate the distance between each pixels present in two images thats stored in database in java code
A:
Assuming you know the x
and y
coordinates of the two pixels, (x1, y1)
and (x2, y2)
, you want to find the distance between:
public static Double getDistance(Integer x1, Integer y1, Integer x2, Integer y2) {
return Math.sqrt(Math.pow(x1 - x2, 2.0) + Math.pow(y1 - y2, 2.0));
}
Dolph
2010-07-05 05:04:00
Or you could just use `Math.hypot(x,y)`. :-\
Gunslinger47
2010-07-05 05:46:49
Also, you could store your points in `java.awt.Point` objects and use the `distance(Point)` methods.
Gunslinger47
2010-07-05 05:51:23
Yeah, but I don't think the OP knows what he's asking for anyway... I chose to stick with boxed primitives :)
Dolph
2010-07-05 19:36:33
A:
Bragboy
2010-07-05 05:05:52