morph_skeleton_cvip() - perform morphological skeletonization of a binary image.
[outImage] = morph_skeleton_cvip(inImage, filtSkel, numIter, masksType, method)
Input Parameters include :
- inImage - Binary image of MxN size. If not binary image, binary thresholding is performed on input image before skeletonization.
- filtSkel - Skeletonization filter or mask of K*K size. K must be a positive odd integer. Use thinskel_mask_cvip function to create an initial mask. The function can create diagonal or non-diagonal mask. if maskType = 0, filtSkel must be diagonal mask if maskType = 1, filtSkel must be non-diagonal mask if maskType = 2, filtSkel must either diagonal or non-diagonal mask (Default: filtSkel = [0 0 0; nan 1 nan; 1 1 1];)
- numIter - Number of iterations (usually 2-20). (Default: 10)
- masksType - Type of masks based on connectivity. masksType = 0 for four diagonal masks. masksType = 1 for four horizontal/vertical masks. masksType = 2 for eight directional masks. (Default: 1)
- method - Method to combine thinning results from all directions. method = 0, AND method method = 1, Sequential method (Default: 0)
Output Parameter includes :
- outImage - Output image of skeletonization operation.
The function performs morphological skeletonization on a binary image. If input image is color or gray-scale image, first, binary thresholding is performed on the input image. Then, morphological skeletonization is performed on binary image. The skeletonization filter or mask is square matrix containing 0's,1's and x's or "don't care". Here,don't care element is represented by NaN value. And,don't care elements can match with either 0s or 1s.
1. Scott E Umbaugh. DIGITAL IMAGE PROCESSING AND ANALYSIS: Applications with MATLAB and CVIPtools, 3rd Edition.
% Read image inimage = imread('Shapes.bmp'); % Skeletonization filter filtSkel1 = [0 0 0;nan 1 nan;1 1 1]; filtSkel2 = [0 0 0; nan 1 nan; 1 nan 1]; % Number of iterations numIter1 = 10; numIter2 = 15; % masksType masksType1 = 1; masksType2 = 2; % Method to combine thinning results from all directions. method1 = 0; method2 = 1; % Call function [outImage1] = morph_skeleton_cvip(inimage, filtSkel1, numIter1, masksType1, method1); [outImage2] = morph_skeleton_cvip(inimage, filtSkel2, numIter2, masksType2, method2); % Display input image figure;imshow(inimage);title('Input Image'); % Display output image figure; imshow(outImage1,); title('Morphological skeleton with default parameters'); figure; imshow(outImage2,); title('Morphological skeleton with user-specified parameters');