CPLremoveregionsholes

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 4.7, Creation date: 2019-07-19, Last change: 2025-09-14

removes CPLs of small areas and small holes using the polyshape class



See Also: CPLregionsholes , CPLremstraightAmin , CPLremovearea , imofimsketch

Example Illustration

 missing image of CPLremoveregionsholes(CPL,sline)

Syntax

CPLN=CPLremoveregionsholes(CPL,[sline])

Input Parameter

CPL: Original CPL
sline: minimal length (not area)

Output Parameter

CPLN: CPL without removed areas

Examples


I=rgbsketch; imshow(I); shg;
imshow(imofimsketch(I));shg
CPLremovearea(CPLofimage(I))
CPLremovearea(CPLofimage(imofimsketch(I)))




Copyright 2019-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, CPLremoveregionsholes, is designed to process closed polygon lists (CPL) by removing regions with small areas and small holes. It utilizes the polyshape class for geometric operations.

Input Parameters

Output

Algorithm Steps

  1. Check if the input CPL is a polyshape object. If so, convert it to a CPL using CPLofCPS.
  2. Extract the outer and inner regions of the CPL using CPLregionsholes, resulting in CPLo and CPLi.
  3. Remove small areas from both CPLo and CPLi using the CPLremovearea function, with sline as the threshold.
  4. Compute the boolean difference between CPLo and CPLi using CPLbool with the '-' operation, resulting in CPLN.
  5. Calculate the difference between the original CPL and CPLN to get CPLX.
  6. If no output is requested, plot the results using CPLplot and CPSplot to visualize the changes.

Additional Notes

The function includes commented-out code that suggests an alternative method for determining the size threshold based on the bounding box of the CPL. This part is not active in the current implementation.

Algorithm explaination created using ChatGPT on 2025-08-19 07:51. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21