-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
A redundant logic in distanceTransform. #23060
Copy link
Copy link
Closed
Labels
category: documentationDocumentation fix or updateDocumentation fix or updatecleanupCode cleanup (e.g, drop legacy C-API, legacy unmaintained code)Code cleanup (e.g, drop legacy C-API, legacy unmaintained code)feature
Milestone
Description
Version
OpenCV 4.7.0.
Issue
opencv/modules/imgproc/src/distransform.cpp
Lines 729 to 746 in 9208dcb
| if( need_labels ) | |
| { | |
| CV_Assert( labelType == DIST_LABEL_PIXEL || labelType == DIST_LABEL_CCOMP ); | |
| _labels.create(src.size(), CV_32S); | |
| labels = _labels.getMat(); | |
| maskSize = CV_DIST_MASK_5; | |
| } | |
| float _mask[5] = {0}; | |
| if( maskSize != CV_DIST_MASK_3 && maskSize != CV_DIST_MASK_5 && maskSize != CV_DIST_MASK_PRECISE ) | |
| CV_Error( CV_StsBadSize, "Mask size should be 3 or 5 or 0 (precise)" ); | |
| if( distType == CV_DIST_C || distType == CV_DIST_L1 ) | |
| maskSize = !need_labels ? CV_DIST_MASK_3 : CV_DIST_MASK_5; | |
| else if( distType == CV_DIST_L2 && need_labels ) | |
| maskSize = CV_DIST_MASK_5; |
if( need_labels )
{
……
maskSize = CV_DIST_MASK_5;
} The maskSize is set to CV_DIST_MASK_5 if (need_labels). Meaning, the follow-up code
if( distType == CV_DIST_C || distType == CV_DIST_L1 )
maskSize = !need_labels ? CV_DIST_MASK_3 : CV_DIST_MASK_5;
else if( distType == CV_DIST_L2 && need_labels )
maskSize = CV_DIST_MASK_5; does the same as
if((distType == CV_DIST_C || distType == CV_DIST_L1) && !need_labels)
maskSize = CV_DIST_MASK_3;.
- The redundant code should be removed.
- The
maskSizebeing set toCV_DIST_MASK_5if (need_labels), no matter whatmaskSizeis provided, is undocumented behavior, and should be properly documented.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
category: documentationDocumentation fix or updateDocumentation fix or updatecleanupCode cleanup (e.g, drop legacy C-API, legacy unmaintained code)Code cleanup (e.g, drop legacy C-API, legacy unmaintained code)feature