Updated on 2024-04-02 GMT+08:00

Super Resolution

Function

This API can compensate insufficient or lost image information due to excessively insufficient pixels or compression. It uses deep learning algorithms to add missing information to images to achieve better visual effect. After you upload the image to be processed, Super Resolution returns the processed image to you.

Prerequisites

Before using Super Resolution, you need to apply for the service and complete authentication. For details, see Applying for a Service and Authentication.

URI

URI format

POST /v1.0/vision/super-resolution

Request Message

Table 1 describes the request parameters.
Table 1 Parameter description

Parameter

Mandatory

Type

Description

image

Configure either this parameter or file.

String

Indicates the Base64 character string converted from the image. The size cannot exceed 10 MB. The supported image formats include JPEG, PNG, and BMP.

file

Configure either this parameter or image.

File

Indicates the image file.

scale

No

Integer

Indicates the magnification factor. The default value is 3. The value can be 3 or 4.

model

No

String

Indicates the algorithm model. The default value is ESPCN.

Possible values are as follows:

ESPCN: Efficient Sub-Pixel Convolutional Neural Network

SRCNN: Super-Resolution Convolutional Neural Network

Response Message

  • Table 2 describes the response parameters of Base64-encoded character strings.
    Table 2 Parameter description

    Parameter

    Type

    Description

    result

    String

    Indicates the Base64 character string converted from the image when the API is successfully called.

    This parameter is not included when the API fails to be called.

    error_code

    String

    Indicates the error code of a failed API call. For details, see Error Codes.

    This parameter is not included when the API is successfully called.

    error_msg

    String

    Indicates the error message of a failed API call.

    This parameter is not included when the API is successfully called.

  • Table 3 describes the response parameters of image files.
    Table 3 Parameter description

    Parameter

    Type

    Description

    error_code

    String

    Indicates the error code of a failed API call. For details, see Error Codes.

    This parameter is not included when the API is successfully called.

    error_msg

    String

    Indicates the error message of a failed API call.

    This parameter is not included when the API is successfully called.

Examples

  • Example request (Method 1: Use a Base64-encoded image.)
    POST https://image.ap-southeast-1.myhuaweicloud.com/v1.0/vision/super-resolution
        
    Request Header:      
    Content-Type:application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...   
    Request Body:
    {  "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj...",
      "scale":3,
      "model":"ESPCN"
    }
  • Example request (Method 2: Use an image file.)
    POST https://image.ap-southeast-1.myhuaweicloud.com/v1.0/vision/super-resolution
        
    Request Header:      
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
         
    Request Body(form-data):
    file: File (image file)
    scale:3
    model:ESPCN

Method 1: Use a Base64-encoded image.

  • Example successful response
    {
     "result":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTc6MTA6MjAgMTA6NDU6MzYAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAALIKADAAQAAAABAAAGQAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABAj..."
    }
  • Example failed response
    {
        "error_code": "AIS.0105",
        "error_msg": "Recognize Failed"
    }

Method 2: Use an image file.

  • Example successful response

    When the API is successfully called, the byte stream of the image file is returned.

  • Example failed response
    {
        "error_code": "AIS.0105",
        "error_msg": "Recognize Failed"
    }

Return Value

  • Normal

    200

  • Abnormal

    Return Value

    Description

    400

    • The request cannot be understood by the server due to malformed syntax. The client should not repeat the request without modifications.
    • The request parameter is incorrect.

    401

    The request requires user authentication.

    403

    No operation permission.

    404

    The server has not found anything matching the Request-URI.

    500

    The server encountered an unexpected condition which prevented it from fulfilling the request.