matlabimage-processinglineorientationmathematical-morphology

How to find the maximum of opening in all orientations at a point in an image?


I need a bit of help. I am trying to segment out sort of zig-zag patterns in an image. I've an algorithm for this. For that I'm opening the image with a line structuring element. I want to perform repeated opening of the image using the line strel at various angles and find maximum of them at each pixel.

Following is a code snippet:

    while(i<360)
         se=strel('line',17,i);
         i=i+15;
         img=imopen(img,se);
    end;

Any help with the implementation will be appreciated.


Solution

  • From what I understand, you want to get maximum for each pixel from a stack of "opened" images?

    % I assume the img is a 2D image (e.g. gray-scale one)
    stack = [];
    
    while(i<360)
             se=strel('line',17,i);
             i=i+15;
             stack(:,:, end+1) =imopen(img,se);
    end;
    

    The opened images will stack up in the stack matrix. Then to find maximum at each pixel, you can just search for maximum in 3th dimension:

    max_pixels = max(stack, 3);