Search code examples
matlabimage-processingregionindices

Get outer indecies of a region in a logical image


If I've any m x n logical image of a white region like the following:

Logical image of a region

How to get the indices of the boundary line between the white and black regions?


Solution

  • This simply comes down to detecting the edges of the given image. MATLAB already has a built-in implementation for that in the edge command. Here's an example of detecting the boundaries of an image I using the Canny filter:

    A = edge(I, 'canny');
    

    The non-zero elements in the resulting image A are what you're after. You can then use find to obtain their indices.