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[2]= | ![]() |
In[3]:= | ![]() |
Out[3]= | ![]() |
Delete rectangles with high overlap and display the results in red along with the original rectangles in black:
In[4]:= | ![]() |
Out[4]= | ![]() |
Only keep non-overlapping rectangles:
In[5]:= | ![]() |
Out[5]= | ![]() |
Perform non-max suppression on a list of regions:
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
In[8]:= | ![]() |
Out[8]= | ![]() |
Provide an explicit list of weights:
In[9]:= | ![]() |
Out[11]= | ![]() |
Performing non-maximum suppression eliminated some of the rectangles:
In[12]:= | ![]() |
Out[13]= | ![]() |
Show the result:
In[14]:= | ![]() |
Out[14]= | ![]() |
Ask for a specific property:
In[15]:= | ![]() |
Out[15]= | ![]() |
The index is determined by the order of the scores for rectangles that contained in the result:
In[16]:= | ![]() |
Out[16]= | ![]() |
Ask for a list of properties:
In[17]:= | ![]() |
Out[19]= | ![]() |
Ask for all properties:
In[20]:= | ![]() |
Out[20]= | ![]() |
Specify an AcceptanceThreshold for the regions:
In[21]:= | ![]() |
Out[21]= | ![]() |
In[22]:= | ![]() |
Out[22]= | ![]() |
Specify values to use before and after the overlap filtering:
In[23]:= | ![]() |
Out[23]= | ![]() |
In[24]:= | ![]() |
Out[24]= | ![]() |
Use MaxOverlapFraction→f to only keep regions with an overlap smaller than f:
In[25]:= | ![]() |
Out[25]= | ![]() |
In[26]:= | ![]() |
Out[26]= | ![]() |
If soft NMS is used, MaxOverlapFraction is used to defined the scaling behaviour:
In[27]:= | ![]() |
Out[27]= | ![]() |
If the a scaling value is given explicitly, the option is ignored:
In[28]:= | ![]() |
Out[28]= | ![]() |
By default, regions are removed using a hard overlap threshold:
In[29]:= | ![]() |
Out[31]= | ![]() |
In[32]:= | ![]() |
Out[32]= | ![]() |
Filter boxes using a soft NMS that scales the weights based on the overlap:
In[33]:= | ![]() |
Out[33]= | ![]() |
Specify the scaling value used to update the regions weights:
In[34]:= | ![]() |
Out[34]= | ![]() |
Soft NMS can become very slow if boxes are not removed:
In[35]:= | ![]() |
In[36]:= | ![]() |
Out[36]= | ![]() |
In[37]:= | ![]() |
Out[37]= | ![]() |
Even a small threshold can significantly speed-up the computation:
In[38]:= | ![]() |
Out[38]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License