使用计算机视觉生成智能裁剪的缩略图Generating smart-cropped thumbnails with Computer Vision

缩略图是图像的缩减表示形式。A thumbnail is a reduced-size representation of an image. 缩略图用于以更加经济且更适合布局的方式表示图像及其他数据。Thumbnails are used to represent images and other data in a more economical, layout-friendly way. 计算机视觉 API 利用智能裁剪及图像大小调整,来创建给定图像的直观缩略图。The Computer Vision API uses smart cropping, together with resizing the image, to create intuitive thumbnails for a given image.

计算机视觉缩略图生成算法的工作原理如下:The Computer Vision thumbnail generation algorithm works as follows:

  1. 从图像中删除让人分散注意力的元素并识别感兴趣区域—显示主要对象的图像区域。Remove distracting elements from the image and identify the area of interest—the area of the image in which the main object(s) appears.
  2. 基于所识别的感兴趣区域裁剪图像。Crop the image based on the identified area of interest.
  3. 更改纵横比以适应目标缩略图尺寸。Change the aspect ratio to fit the target thumbnail dimensions.

感兴趣区域Area of interest

上传图像时,计算机视觉 API 将对图像进行分析,以确定感兴趣区域。When you upload an image, the Computer Vision API analyzes it to determine the area of interest. 然后它可使用该区域来确定如何裁剪图像。It can then use this region to determine how to crop the image. 但是,如果已指定所需的纵横比,则裁剪操作始终会与之匹配。The cropping operation, however, will always match the desired aspect ratio if one is specified.

此外,还可改为调用 areaOfInterest API 来获取同一个感兴趣区域的原始边界框坐标。You can also get the raw bounding box coordinates of this same area of interest by calling the areaOfInterest API instead. 然后可以使用此信息并根据需要来修改原始图像。You can then use this information to modify the original image however you wish.

示例Examples

生成的缩略图可能会根据指定的高度、宽度和智能裁剪的不同而有很大差异,如下图所示。The generated thumbnail can vary widely depending on what you specify for height, width, and smart cropping, as shown in the following image.

各种裁剪配置旁边的一个山脉图像

下表说明了计算机视觉为示例图像生成的典型缩略图。The following table illustrates typical thumbnails generated by Computer Vision for the example images. 生成缩略图的指定目标高度和宽度为 50 像素,并且启用了智能裁剪。The thumbnails were generated for a specified target height and width of 50 pixels, with smart cropping enabled.

映像Image 缩略图Thumbnail
日落时户外的大山以及人的轮廓 日落时户外的大山以及人的轮廓的缩略图
具有绿色背景的白色花卉 视觉分析花缩略图
在公寓楼顶上的一个女人 在公寓楼顶上的一个女人的缩略图

后续步骤Next steps

了解标记图像对图像进行分类Learn about tagging images and categorizing images.