Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Filter regions based on their overlap
ResourceFunction["NonMaximumSuppression"][{reg1,reg2,…}] keeps the rectangular regions regi with low overlap between each other. | |
ResourceFunction["NonMaximumSuppression"][{reg1,…}→{w1,…}] uses the weights wi to score the importance of each regi. | |
ResourceFunction["NonMaximumSuppression"][regions,property] gives the specified property for the filtered regions. |
"Index" | position of the selected region |
"Region" | selected region |
"Weight" | the weight used to score the region |
{prop1,…} | a list of properties |
All | all the available properties |
AcceptanceThreshold | Automatic | region acceptance threshold |
MaxOverlapFraction | Automatic | maximum allowed overlap fraction |
Method | "Hard" | method to use |
"Hard" | remove regions with overlap greater than the specified threshold |
"Soft" | iteratively rescore the regions based on their overlap |
Filter out rectangles from list that have a big overlap with other rectangles in the list:
In[1]:= |
Out[1]= |
Define and display a list of rectangle shapes:
In[2]:= |
Out[3]= |
In[4]:= |
Out[4]= |
Delete rectangles with high overlap and display the results in red along with the original rectangles in black:
In[5]:= |
Out[6]= |
Only keep non-overlapping rectangles:
In[7]:= |
Out[8]= |
Perform non-max suppression on a list of regions:
In[9]:= |
Out[10]= |
In[11]:= |
Out[11]= |
In[12]:= |
Out[12]= |
Provide an explicit list of weights:
In[13]:= |
Out[15]= |
Performing non-maximum suppression eliminated some of the rectangles:
In[16]:= |
Out[17]= |
Show the result:
In[18]:= |
Out[18]= |
Ask for a specific property:
In[19]:= |
Out[20]= |
The index is determined by the order of the scores for rectangles that contained in the result:
In[21]:= |
Out[21]= |
Ask for a list of properties:
In[22]:= |
Out[24]= |
Ask for all properties:
In[25]:= |
Out[25]= |
Specify an AcceptanceThreshold for the regions:
In[26]:= |
Out[27]= |
In[28]:= |
Out[28]= |
Use MaxOverlapFraction→f to only keep regions with an overlap smaller than f:
In[29]:= |
Out[30]= |
In[31]:= |
Out[31]= |
If soft NMS is used, MaxOverlapFraction is used to defined the scaling behaviour:
In[32]:= |
Out[34]= |
If the a scaling value is given explicitly, the option is ignored:
In[35]:= |
Out[35]= |
By default, regions are removed using a hard overlap threshold:
In[36]:= |
Out[37]= |
In[38]:= |
Out[38]= |
Filter boxes using a soft NMS that scales the weights based on the overlap:
In[39]:= |
Out[40]= |
Specify the scaling value used to update the regions weights:
In[41]:= |
Out[42]= |
Soft NMS can become very slow if boxes are not removed:
In[43]:= |
In[44]:= |
Out[44]= |
In[45]:= |
Out[45]= |
Even a small threshold can significantly speed-up the computation:
In[46]:= |
Out[46]= |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License