Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Crop an image while preserving the most salient contents
ResourceFunction["ImageSaliencyCrop"][img,a] crops img to have an AspectRatio of a such that the result contains the most salient region of img. | |
ResourceFunction["ImageSaliencyCrop"][img] crops img to have an AspectRatio of 1, such that the result contains the most salient region of img. | |
ResourceFunction["ImageSaliencyCrop"][img,{w,h}] crops img to width w and height h, keeping the most salient region of img. |
Method | Automatic | choose a method for determining saliency |
"CentralityWeight" | 1 | priority for centering salient features |
"Itti" | saliency based on color,intensity and orientation |
"IttiColor" | color map of the Itti algorithm |
"IttiIntensity" | intensity map of the Itti algorithm |
"IttiOrientation" | orientation map of the Itti algorithm |
"HistogramContrast" | saliency based on mean color difference to image pixels |
"SpectralResidual" | saliency based on the residual of the log spectrum |
"ImageSignature" | saliency based on foreground estimation |
Crop an image into a square aspect ratio, focusing on the salient contents:
In[1]:= |
Out[1]= |
Choose the target aspect ratio:
In[2]:= |
Out[2]= |
Choose the target image size:
In[3]:= |
Out[3]= |
"CentralityWeight" can be a value between -4 and 4. It changes the priority of placing the most salient features in the center of the image. If there are two salient points in the image, a high "CentralityWeight" will prefer to center on the most important. A low "CentralityWeight" will try to get both features in the output image:
In[5]:= |
Out[5]= |
In[6]:= |
Out[6]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License