3

I am new to opencv and good at matlab

i want to write equalent of below to opencv

[mm,nn]=size(binaryimage);

bwperim(binaryimage);

Please can any one help

smile
  • 169
  • 2
  • 4
  • 13

2 Answers2

2

There is a library for these things: http://opencv.willowgarage.com/wiki/cvBlobsLib

AVB
  • 3,994
  • 22
  • 21
0

For emulating bwperim you can do

Mat m;
Mat dilated = m.clone(); dilate(dilated,one_pixel_wide_element);
Mat output = dilated - m;

where the one_pixel_wide_element can be constructed using instructions from opencv:

  dilation_type = MORPH_RECT;
  dilation_size = 1;
  Mat element = getStructuringElement( dilation_type,
                  Size( 2*dilation_size + 1, 2*dilation_size+1 ),
                  Point( dilation_size, dilation_size ) );

This gives an outer boundary. For inner boundaries do erode (and m-eroded).

Barney Szabolcs
  • 11,846
  • 12
  • 66
  • 91