imgsmlr
imgsmlr : Image similarity with haar
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2830 | imgsmlr | imgsmlr | 1.0 |
FEAT | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-r | No | Yes | No | Yes | yes | no |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 |
18 17 16 15 14 | imgsmlr |
- |
| RPM | PIGSTY | 1.0 |
18 17 16 15 14 | imgsmlr_$v |
- |
| DEB | PIGSTY | 1.0 |
18 17 16 15 14 | postgresql-$v-imgsmlr |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| el8.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| el9.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| el9.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| el10.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| el10.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| d12.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| d12.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| d13.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| d13.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u22.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u22.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u24.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u24.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u26.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u26.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
Source
github.com/postgrespro/imgsmlr
imgsmlr-1.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
imgsmlr: similar images search for PostgreSQL using Haar wavelet transform
The imgsmlr extension implements similar image searching functionality based on Haar wavelet transforms. It provides two data types and functions for converting images into searchable signatures.
Data Types
| Datatype | Storage Length | Description |
|---|---|---|
pattern |
16388 bytes | Result of Haar wavelet transform on the image |
signature |
64 bytes | Short representation of pattern for fast GiST index searches |
Functions
| Function | Return Type | Description |
|---|---|---|
jpeg2pattern(bytea) |
pattern | Convert JPEG image data into pattern |
png2pattern(bytea) |
pattern | Convert PNG image data into pattern |
gif2pattern(bytea) |
pattern | Convert GIF image data into pattern |
pattern2signature(pattern) |
signature | Create signature from pattern |
shuffle_pattern(pattern) |
pattern | Shuffle pattern for less sensitivity to image shift |
Operators
| Operator | Left | Right | Return | Description |
|---|---|---|---|---|
<-> |
pattern | pattern | float8 | Euclidean distance between two patterns |
<-> |
signature | signature | float8 | Euclidean distance between two signatures |
The signature type supports GiST indexing with KNN on the <-> operator.
Example
Create a table of patterns and signatures from JPEG images:
Search for the top 10 similar images to a given image:
The inner query selects the top 100 candidates by signature using the GiST index. The outer query refines to the top 10 by pattern distance.