views:

80

answers:

2

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
Or you could just use `Math.hypot(x,y)`. :-\
Gunslinger47
Also, you could store your points in `java.awt.Point` objects and use the `distance(Point)` methods.
Gunslinger47
Yeah, but I don't think the OP knows what he's asking for anyway... I chose to stick with boxed primitives :)
Dolph
A: 
Bragboy