Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

MatchTemplate on a single color

I am attempting to compare the quality of a black&white map built by a robot running slam, with a ground truth map using MatchTemplate. When I call MatchTemplate on both maps, the result is far from accurate - the matching region is way off.

Please look at the image attached, which is a hand-drawn example of what happens: Maps. On the left is the ground truth and on the right is the slam map of a single room (say that I stopped my slam algorithm at this point). The gray rectangles represent the boundaries of each image. I would expect MatchTemplate to locate the room at the bottom left corner of the ground truth (where it should be), but it doesn't. In fact, the algorithm would match it where a lot of white can be found (such as the region enclosed by the green rectangle). Therefore, the white regions of my slam map affect the result of the algorithm.

I thought of two solutions, but I don't know how to apply them. First, is there a way of setting MatchTemplate to only take black into account and ignore white completely? Second, is it possible to enclose my slam map with a non-rectangular mask (the rooms are not always rectangular)? If not, is there another algorithm that would best fit my purpose?

I found several topics on using MatchTemplate with masks or transparency, but the solutions to these questions don't seem to apply to my case. For instance, I tried using edge detection prior to using MatchTemplate, but it doesn't work since my original map is approximately equivalent to an image on which edge detection was already applied (obviously!).

MatchTemplate on a single color

I am attempting to compare the quality of a black&white map built by a robot running slam, with a ground truth map using MatchTemplate. When I call MatchTemplate on both maps, the result is far from accurate - the matching region is way off.

Please look at the image attached, which is a hand-drawn example of what happens: MapsMaps. On the left is the ground truth and on the right is the slam map of a single room (say that I stopped my slam algorithm at this point). The gray rectangles represent the boundaries of each image. I would expect MatchTemplate to locate the room at the bottom left corner of the ground truth (where it should be), but it doesn't. In fact, the algorithm would match it where a lot of white can be found (such as the region enclosed by the green rectangle). Therefore, the white regions of my slam map affect the result of the algorithm.

I thought of two solutions, but I don't know how to apply them. First, is there a way of setting MatchTemplate to only take black into account and ignore white completely? Second, is it possible to enclose my slam map with a non-rectangular mask (the rooms are not always rectangular)? If not, is there another algorithm that would best fit my purpose?

I found several topics on using MatchTemplate with masks or transparency, but the solutions to these questions don't seem to apply to my case. For instance, I tried using edge detection prior to using MatchTemplate, but it doesn't work since my original map is approximately equivalent to an image on which edge detection was already applied (obviously!).

MatchTemplate on a single color

I am attempting to compare the quality of a black&white map built by a robot running slam, with a ground truth map using MatchTemplate. map. I decided to try MatchTemplate for that purpose. When I call MatchTemplate on both maps, the result is far from accurate - the matching region is way off.

Please look at the image attached, which is a hand-drawn example of what happens: Maps. On the left is the ground truth and on the right is the slam map of a single room (say that I stopped my slam algorithm at this point). The gray rectangles represent the boundaries of each image. I would expect MatchTemplate to locate the room at the bottom left corner of the ground truth (where it should be), but it doesn't. In fact, the algorithm would match it where a lot of white can be found (such as the region enclosed by the green rectangle). Therefore, the white regions of my slam map affect the result of the algorithm.

I thought of two solutions, but I don't know how to apply them. First, is there a way of setting MatchTemplate to only take black into account and ignore white completely? Second, is it possible to enclose my slam map with a non-rectangular mask (the rooms are not always rectangular)? If not, is there another algorithm that would best fit my purpose?purpose?

I found several topics on using MatchTemplate with masks or transparency, but the solutions to these questions don't seem to apply to my case. For instance, I tried using edge detection prior to using MatchTemplate, but it doesn't work since my original map is approximately equivalent to an image on which edge detection was already applied (obviously!).

I hope I made myself clear!

MatchTemplate on a single color

I am attempting to compare the quality of a black&white map built by a robot running slam, slam with a ground truth map. I decided to try MatchTemplate for that purpose. When I call MatchTemplate on both the function on the maps, the result is far from accurate - the matching region is way off.

Please look at the image attached, which is a hand-drawn example of what happens: Maps. On the left is the ground truth and on the right is the slam map of a single room (say that I stopped my slam algorithm at this point). The gray rectangles represent the boundaries of each image. I would expect MatchTemplate to locate the room at the bottom left corner of the ground truth (where it should be), but it doesn't. In fact, the algorithm would match it where a lot of white can be found (such as the region enclosed by the green rectangle). Therefore, the white regions of my slam map affect the result of the algorithm.

I thought of two solutions, but I don't know how to apply them. First, is there a way of setting MatchTemplate to only take black into account and ignore white completely? Second, is it possible to enclose my slam map with a non-rectangular mask (the rooms are not always rectangular)? If not, is there another algorithm that would best fit my purpose?

I found several topics on using MatchTemplate with masks or transparency, but the solutions to these questions don't seem to apply to my case. For instance, I tried using edge detection prior to using MatchTemplate, but it doesn't work since my original map is approximately equivalent to an image on which edge detection was already applied (obviously!).

I hope I made myself clear!