图像增强

最近更新时间:2023-12-01 17:57:56

我的收藏

简介

本文档提供关于图像增强的相关 API 概览以及 SDK 示例代码。
API
操作描述
腾讯云数据万象通过 AIEnhanceImage 接口对图像进行增强处理。

图像增强

腾讯云数据万象通过 AIEnhanceImage 接口对图像进行增强处理。

方法原型

func (s *CIService) GetAIEnhanceImageV2(ctx context.Context, name string, opt *AIEnhanceImageOptions) (*Response, error)

请求示例

// 将 examplebucket-1250000000 和 COS_REGION 修改为真实的信息
bu, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")
b := &cos.BaseURL{BucketURL: bu}
c := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: os.Getenv("SECRETID"),
SecretKey: os.Getenv("SECRETKEY"),
}
})
obj := "pic/heibai.jpeg"
localPath := "test.jpeg"
opt := &cos.AIEnhanceImageOptions{}
resp, err := c.CI.GetAIEnhanceImageV2(context.Background(), obj, opt)
log_status(err)
if err == nil {
fd, _ := os.OpenFile(localPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660)
io.Copy(fd, resp.Body)
fd.Close()
}

参数说明

type AIEnhanceImageOptions struct {
DetectUrl string `url:"detect-url,omitempty"`
Denoise int `url:"denoise,omitempty"`
Sharpen int `url:"sharpen,omitempty"`
IgnoreError int `url:"ignore-error,omitempty"`
}
参数名称
参数描述
类型
是否必填
DetectUrl
您可以通过填写 detect-url 处理任意公网可访问的图片链接。不填写 detect-url 时,后台会默认处理 name,填写了 detect-url 时,后台会处理 detect-url 链接,无需再填写 name。
string
Denoise
去噪强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行去噪操作,默认值为3。
int
Sharpen
锐化强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行锐化操作,默认值为3。
int
IgnoreError
当此参数为1时,针对文件过大等导致处理失败的场景,会直接返回原图而不报错。
int

结果说明

处理后的图片直接返回至响应体。