You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Image processing
Image sharpness calculation
Copy page
Download PDF
Image sharpness calculation

Operator ID: daft.las.functions.image.image_sharpness.ImageSharpness

Operator introduction

Description

Image sharpness calculation processor that supports multiple sharpness evaluation methods.

Key features

  • Provides four professional-grade sharpness evaluation methods:
    • Laplacian variance method (laplacian) – Edge detection based on second-order derivatives, simple and fast computation
    • Tenengrad method (tenengrad) – Edge strength based on Sobel gradients, sensitive to noise
    • Brenner method (brenner) – Simple calculation based on the grayscale difference of adjacent pixels, the fastest method
    • FFT high-frequency energy method (fft_highfreq) – Sharpness evaluation based on frequency domain analysis, more sensitive to blurring
  • Multi-format input support:
    • URL address (image_url)
    • Base64 encoding (image_base64)
    • Binary stream (image_binary)
  • High-precision calculation:
    • Supports processing images of various sizes and formats
    • Automatically handles NaN values and exception cases

Cautions and prerequisites

Details

Caution and prerequisites

Costs

Before calling an operator, you need to understand the model invocation costs associated with using the operator. For details, see Large model invocation billing.

Authentication (API Key)

Before calling an operator, you need to generate an API Key for operator invocation. It is recommended to configure the API Key as an environment variable to ensure safer operator calls. For details, see Obtain and configure API Key.

BaseURL

Before calling an operator, you need to determine the BaseURL for operator invocation based on the region where your current LAS service is deployed. This is used to configure the path parameter values for operator calls.
For details, see Obtain the Base URL. The Examples below are for reference only; when making actual calls, replace the path values with those corresponding to your region.

Daft invocation

Operator parameters

Input

Input column name

Description

images

Array containing the input images, supports URL, Base64, and binary formats

Output

Floating-point array containing the sharpness calculation results

Parameters

If a parameter does not have a default value, it is required

Parameter name

Type

Default value

Description

image_src_type

str

"image_url"

The format type of the input image, supports:

  • image_url: URL address
  • image_base64: Base64 encoding
  • image_binary: binary stream

Default value: "image_url"

method

str

"laplacian"

Sharpness calculation method, supports:

  • laplacian (Laplacian variance)
  • tenengrad (Tenengrad gradient)
  • brenner (Brenner gradient)
  • fft_highfreq (FFT high-frequency energy)

The default is laplacian.

Examples

The following code demonstrates how to use daft to run the operator for image sharpness calculation.

from __future__ import annotations

import os

import daft
from daft import col
from daft.las.functions.image.image_sharpness import ImageSharpness
from daft.las.functions.udf import las_udf

if __name__ == "__main__":
    if os.getenv("DAFT_RUNNER", "native") == "ray":
        import logging

        import ray

        def configure_logging():
            logging.basicConfig(
                level=logging.INFO,
                format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
                datefmt="%Y-%m-%d %H:%M:%S.%s".format(),
            )
            logging.getLogger("tracing.span").setLevel(logging.WARNING)
            logging.getLogger("daft_io.stats").setLevel(logging.WARNING)
            logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING)

        ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging})
        daft.set_runner_ray()
    daft.set_execution_config(actor_udf_ready_timeout=600)
    daft.set_execution_config(min_cpu_per_task=0)


    tos_dir_url = os.getenv("TOS_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com")
    samples = {
        "image": [
            f"https://{tos_dir_url}/public/shared_image_dataset/cat_ip_adapter.jpeg"
        ],
    }

    image_src_type = "image_url"
    method = "laplacian"
    num_gpus = 0

    ds = daft.from_pydict(samples)
    ds = ds.with_column(
        "image_sharpness",
        las_udf(
            ImageSharpness,
            construct_args={
                "image_src_type": image_src_type,
                "method": method,
            },
            num_gpus=num_gpus,
            batch_size=1,
        )(col("image")),
    )

    ds.show()

    # ╭────────────────────────────────┬───────────────────────╮
    # │ image                          ┆ image_sharpness       │
    # │ ---                            ┆ ---                   │
    # │ Utf8                           ┆ Float64               │
    # ╞════════════════════════════════╪═══════════════════════╡
    # │ https://las-cn-beijing-public… ┆ 1234.56               │
    # ╰────────────────────────────────┴───────────────────────╯
Last updated: 2026.05.24 15:23:18