On a shape from a logical image, I am trying to extract the field of view from any point inside the shape on matlab :
I tried something involving to test each line going through the point but it is really really long.(I hope to do it for each points of the shape or at least each point of it's contour wich is quite a few times)
I think a faster method would be working iteratively by the expansion of a disk from the considered point but I am not sure how to do it.
How can I find this field of view in an efficient way?
Any ideas or solution would be appreciated, thanks.
Here is a possible approach (the principle behind the function I wrote, available on Matlab Central):
I created this test image and an arbitrary point of view:
It looks like this (the circle marks the view point I chose):
The next line computes the longest distance to the edge of the image from the viewpoint:
Then generate a set of points uniformly distributed around the viewpoint.:
What this does is drawing lines from the view point to each directions specified in the array
angles
and look for the position of the intersection with an obstacle or the edge of the image.This should help visualizing the process:
Finally, let's use the built-in
roipoly
function to create a binary mask from a set of coordinates:Here is how it looks like (obstacles in white, visible field in gray, viewpoint in red):