Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8cfaa57

Browse files
committed
Some more details in readme.
1 parent880f576 commit8cfaa57

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

‎README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,49 @@ Typical installation procedure may look like this:
4444
$ cd imgsmlr
4545
$ make USE_PGXS=1
4646
$ sudo make USE_PGXS=1 install
47-
$ make USE_PGXS=1 installcheck
4847
$ psql DB -c "CREATE EXTENSION imgsmlr;"
4948

5049
Usage
5150
-----
5251

53-
| Type| Storage length| Description|
52+
ImgSmlr offers two datatypes: pattern and signature.
53+
54+
| Datatype| Storage length| Description|
5455
| ---------|--------------:| ------------------------------------------------------------------|
5556
| pattern| 16388 bytes| Result of Haar wavelet transform on the image|
5657
| signature| 64 bytes| Short representation of pattern for fast search using GiST indexes|
5758

59+
There is set of functions*2pattern(bytea) which converts bynary data in given format into pattern. Convertion into pattern consists of following steps.
60+
61+
* Decompress image.
62+
* Make image black&white.
63+
* Resize image to 64x64 pixels.
64+
* Apply Haar wavelet transform to the image.
65+
66+
Pattern could be converted into signature and shuffled for less sensitivity to image shift.
67+
5868
| Function| Return type| Description|
5969
| --------------------------|-------------| ---------------------------------------------------|
6070
| jpeg2pattern(bytea)| pattern| Convert jpeg image into pattern|
6171
| png2pattern(bytea)| pattern| Convert png image into pattern|
6272
| gif2pattern(bytea)| pattern| Convert gif image into pattern|
6373
| pattern2signature(pattern)| signature| Create signature from pattern|
64-
| shuffle_pattern(pattern)| pattern| Shuffle pattern for less sensibility to image shift|
74+
| shuffle_pattern(pattern)| pattern| Shuffle pattern for less sensitivity to image shift|
75+
76+
Both pattern and signature datatypes supports`<->` operator for eucledian distance. Signature also supports GiST indexing with KNN on`<->` operator.
6577

6678
| Operator| Left type| Right type| Return type| Description|
6779
| --------|-----------| ----------| -----------| -----------------------------------------|
6880
| <->| pattern| pattern| float8| Eucledian distance between two patterns|
6981
| <->| signature| signature| float8| Eucledian distance between two signatures|
7082

83+
The idea is to find top N similar images by signature using GiST index. Then find top n (n < N) similar images by pattern from top N similar images by signature.
84+
7185
Example
7286
-------
7387

88+
Let us assume we have an`image` table with columns`id` and`data` where`data` column contains binary jpeg data. We can create`pat` table with patterns and signatures of given images using following query.
89+
7490
```sql
7591
CREATETABLEpatAS (
7692
SELECT
@@ -85,10 +101,17 @@ CREATE TABLE pat AS (
85101
image
86102
) x
87103
);
104+
```
105+
106+
Then let's create primary key for`pat` table and GiST index for signatures.
107+
108+
```sql
109+
ALTERTABLE pat ADDPRIMARY KEY (id);
88110
CREATEINDEXpat_signature_idxON pat USING gist (signature);
89-
CREATEINDEXpat_id_idxON pat(id);
90111
```
91112

113+
Prelimimary work is done. Now we can search for top 10 similar images to given image with specified id using following query.
114+
92115
```sql
93116
SELECT
94117
id,
@@ -107,3 +130,5 @@ FROM
107130
ORDER BYx.smlrASC
108131
LIMIT10
109132
```
133+
134+
Inner query selects top 100 images by signature using GiST index. Outer query search for top 10 images by pattern from images found by inner query. You can adjust both of number to achieve better search results on your images collection.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp