开发者

Matlab: obtaining the normals of binary image contour points

开发者 https://www.devze.com 2023-03-03 03:39 出处:网络
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

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]';
0

精彩评论

暂无评论...
验证码 换一张
取 消