Matlab: obtaining the normals of binary image contour points
Context
I have a binary image of a silhouette that I wish to add noise to. The noise should be added only to the contour of the silhouette. I would like the noise to be a vector that is added to each contour point, with the length of the vector being sampled from a Gaussian distribution with zero-mean and a variance of x% of the silhouette height. The direction of the vector should be the normal of the given contour point.
开发者_Go百科Question
In Matlab, given a binary image, how do I obtain the normals of the contour points?
Use bwboundaries
to obtain the contour (i.e. the sequence of points which make the contour). Since you have the sequence of points thanks to bwboundaries
, we can now define 3 points A,B,C where B is between A and C and we want to find the normal at B which is given by:
N = [Ay - Cy;Cx - Ax]';
精彩评论