Skip to content

Drawing

Unstable API 0.10.0 @project-lakechain/image-layer-processor TypeScript

The image layer processor middleware provides the capability to draw layers on top of images. It makes it possible to use images semantic metadata generated by upstream middlewares to draw bounding boxes, blur areas such as text or objects, etc.


🖊️ Highlight Areas

In the below example, we are coupling the Rekognition Image Processor middleware with the image layer processor to draw bounding boxes around detected faces in an image.

💁 The image layer processor uses the information provided by the Rekognition image processor to determine around which area to draw the bounding boxes.

import { RekognitionImageProcessor, dsl as r } from '@project-lakechain/rekognition-image-processor';
import { ImageLayerProcessor, dsl as l } from '@project-lakechain/image-layer-processor';
import { CacheStorage } from '@project-lakechain/core';
class Stack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string) {
const cache = new CacheStorage(this, 'Cache');
// Create the Rekognition image processor.
const rekognitionProcessor = new RekognitionImageProcessor.Builder()
.withScope(this)
.withIdentifier('ImageProcessor')
.withCacheStorage(cache)
.withSource(source)
.withIntent(
r.detect().faces(r.confidence(80)) // 👈 Face detection
)
.build();
// Create the image layer processor.
const layerProcessor = new ImageLayerProcessor.Builder()
.withScope(this)
.withIdentifier('LayerProcessor')
.withCacheStorage(cache)
.withSource(rekognitionProcessor)
.withLayers(
l.highlight(l.faces()) // 👈 Highlight faces
)
.build();
}
}


Examples


Face HighlightingObject Highlighting
Face HighlightingObject Highlighting


Operations

Below is a list of subjects that the highlight operation supports and that follow the same logic as in the previous example. These subjects are used to highlight different areas of the image, and expect upstream middlewares to provide the necessary semantic metadata to do so.

SubjectDescription
facesHighlight faces on the image.
objectsHighlight objects on the image.
textHighlight text on the image.
landmarksHighlight face landmarks on the image.


👾 Pixelate

Another drawing operation supported by this middleware is its ability to pixelate areas of images based on semantic metadata provided by upstream middlewares.

💁 In the below example, we are blurring the faces detected from images.

import { RekognitionImageProcessor, dsl as r } from '@project-lakechain/rekognition-image-processor';
import { ImageLayerProcessor, dsl as l } from '@project-lakechain/image-layer-processor';
import { CacheStorage } from '@project-lakechain/core';
class Stack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string) {
const cache = new CacheStorage(this, 'Cache');
// Create the Rekognition image processor.
const rekognitionProcessor = new RekognitionImageProcessor.Builder()
.withScope(this)
.withIdentifier('ImageProcessor')
.withCacheStorage(cache)
.withSource(source)
.withIntent(
r.detect().faces(r.confidence(80)) // 👈 Face detection
)
.build();
// Create the image layer processor.
const layerProcessor = new ImageLayerProcessor.Builder()
.withScope(this)
.withIdentifier('LayerProcessor')
.withCacheStorage(cache)
.withSource(rekognitionProcessor)
.withLayers(
l.pixelate(l.faces()) // 👈 Pixelate faces
)
.build();
}
}


Examples


Face pixelationObject pixelation
Face pixelationObject pixelation


Operations

Below is a list of subjects that the pixelate operation supports and that follow the same logic as in the previous example.

SubjectDescription
facesPixelate faces on the image.
objectsPixelate objects on the image.
textPixelate text on the image.


🏗️ Architecture

This middleware runs within a Lambda compute, and packages different libraries as a Docker image to draw semantic metadata on top of images.

Image Layer Processor Architecture



🏷️ Properties


Supported Inputs
Mime TypeDescription
image/jpegThis middleware supports JPEG images as input.
image/pngThis middleware supports PNG images as input.
image/tiffThis middleware supports TIFF images as input.
image/webpThis middleware supports WebP images as input.
Supported Outputs
Mime TypeDescription
image/jpegThis middleware supports JPEG images as output.
image/pngThis middleware supports PNG images as output.
image/tiffThis middleware supports TIFF images as output.
image/webpThis middleware supports WebP images as output.
Supported Compute Types
TypeDescription
CPUThis middleware only supports CPU compute.


📖 Examples