Wrong "error_colormap" function usage
canyagmur opened this issue · 1 comments
In ui/viz.py,
line 289 : color = error_colormap(conf, thr, alpha=0.1)
is used. However, in the implementation of "error_colormap" function :
def error_colormap(
err: np.ndarray, thr: float, alpha: float = 1.0
) -> np.ndarray:
"""
Create a colormap based on the error values.
Args:
err: Error values as a numpy array of shape (N,).
thr: Threshold value for the error.
alpha: Alpha value for the colormap, between 0 and 1.
Returns:
Colormap as a numpy array of shape (N, 4) with values in [0, 1].
"""
assert alpha <= 1.0 and alpha > 0, f"Invaid alpha value: {alpha}"
x = 1 - np.clip(err / (thr * 2), 0, 1)
return np.clip(
np.stack(
[2 - x * 2, x * 2, np.zeros_like(x), np.ones_like(x) * alpha], -1
),
0,
1,
)
np.random.seed(1995)
color_map = np.arange(100)
np.random.shuffle(color_map)
Function expects "err" which is error array as input however conf values are given. Simple solution would be changing the conf values to error values by simply inverting them or defining a new function that defines x as :
x = np.clip(conf, 0, 1) # Ensure values are within [0, 1]
If you don't change this you will see inverted colors, e.g green for bad match red for good match and in between. Also note that colors are in rgb format. If you have image that is in bgr or any other format you should check it cause i also tricked by that :)
Hope this helps anybody confusing match colors.
Fixed by:
image-matching-webui/ui/viz.py
Line 287 in 39ae810