Wolfram Computation Meets Knowledge

ImageSaliencyCrop

Contributed by: Jon McLoone

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.

Details and Options

ResourceFunction["ImageSaliencyCrop"] has the following options:
Method Automatic choose a method for determining saliency
"CentralityWeight" 1 priority for centering salient features
Possible settings for the Method option are:
"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
The Itti algorithm is based on human visual saliency. For all methods based on this algorithm, calculations are performed in the RGB color space.
For all Itti-based methods, different scales of the image are compared with each other. With Method{"method",{σ1,σ2,},{step1,step2,}}, scale σi is compared with coarser scales σi+stepj for all j. The default setting is {"Itti",{2,3,4},{3,4}}.

Examples

Basic Examples

Crop an image into a square aspect ratio, focusing on the salient contents:

In[1]:=
CloudGet["https://www.wolframcloud.com/objects/dafa090e-f2fc-4611-990a-121bc0c5addf"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[1]=

Scope

Choose the target aspect ratio:

In[2]:=
CloudGet["https://www.wolframcloud.com/objects/e1ef25e5-023c-4c40-bd1b-0b21ae869b52"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[2]=

Choose the target image size:

In[3]:=
CloudGet["https://www.wolframcloud.com/objects/f76634e6-7de4-498e-8261-15a89b2bb5ed"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[3]=

Options

Method

ImageSaliencyCrop supports the Method options of ImageSaliencyFilter:

In[4]:=
CloudGet["https://www.wolframcloud.com/objects/87075323-daeb-4663-a657-b0d3498425a5"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[4]=

CentralityWeight

"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]:=
CloudGet["https://www.wolframcloud.com/objects/9bd3df4c-87bc-4b4b-b786-00d8384cb1c3"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[5]=
In[6]:=
CloudGet["https://www.wolframcloud.com/objects/ceedc1ad-d4d0-4a3e-8a83-41a73991e5c7"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[6]=

Resource History