Compute a free space/obstacle mask for an image (pixels) for pixel-level image segmentation

I am working with pixel-level image segmentation in Matlab. I am trying to build a model to classify each pixel in the RGB image either Free space (F) or Obstacle. If the pixel is belonging to an object outside a threshold distance from the camera location then it is free otherwise its an obstacle. The main challenge I have now is labeling the data set. Is there any way I can come up with an algorithm in Matlab that will do the labeling process automatically, apart from image labeler app, i.e compute a mask of (F)/(o) for the image?. Assuming that I have a synthetic 3d environment to collect images from by changing the position and orientation of the camera within the environment. So known things are :
1-Camera properties (focal length, sensor size,..etc)
2-Camera location within the environment (X, Y, Z)
3- Objects' location and dimensions.
please advise me if you have any suggestion.

 Accepted Answer

I don't know how you know if a pixel is free space or not - maybe the color, maybe spatial information from neighboring pixels also? Maybe it's the pixel brightness or color or texture in an immediate neighborhood. But whatever it is, you have to get an image that has the probability (percentage) that each pixel is either obstacle or free space. Then you can simply threshold that.

5 Comments

if an object is within a certain distance from the location of the camera then the object's pixels are not free. then locating those pixels location (XY) within the image and subsequently put obstacle label within the mask (label). that's my first thought but i can't relate, identify, object pixels within the image mathematically.
OK, so compute the distance of every pixel in the scene to your camera. Now you have a distance image. Then threshold that
freePixels = distanceImage > certainDistanceThreshold;
And, of course, obstacle pixels is the reverse of that, if you need it:
obstaclePixels = ~freePixels;
thanks for your answer, how can i calculate the distance to each single pixel from the camera? . for instance, assume that i have an image of a box ,on the floor,that is faraway from the camera, and the whole box's pixels are supposed to be free. i can calculate the object pixels count (height and width) but i cant really know where they are sit in the image. e.g: the image is 500*500 and the box is 30*20 pixels, i dont know where these 600 pixels XY locations within the 250000 pixels are.
sorry if i confused you
I thought that since you were ready to do the labeling that you had it already. If you don't, see the camera calibration capabilities of the Computer Vision System Toolbox: https://www.mathworks.com/products/computer-vision/features.html#camera-calibration
thanks again for the reply, i will accept the answer and have a look at the suggestion.

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Asked:

on 19 Oct 2018

Commented:

on 19 Oct 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!