https://github.com/postgrespro/imgsmlr
1、deploy
apt-get install postgresql-server-dev-all
apt-get install postgresql-common
apt-get install libgd2-noxpm-dev
2、compile
$ git clone https://github.com/postgrespro/imgsmlr.git
$ cd imgsmlr
$ make USE_PGXS=1
$ sudo make USE_PGXS=1 install
$ make USE_PGXS=1 installcheck
3、Enter Database: postgres=#
CREATE EXTENSION imgsmlr;
4、Search Example:
1)CREATE TABLE pat AS ( SELECT name, shuffle_pattern(pattern) AS pattern,pattern2signature(pattern) AS signature FROM (SELECT name, jpeg2pattern(content) AS pattern FROM cataract) x );
2)ALTER TABLE pat ADD PRIMARY KEY (name);
3)CREATE INDEX pat_signature_idx ON pat USING gist (signature);
5、search for top 10 similar images to given image with specified name
name = C020_20180514_100234_R_CASIA2_LGC_000.jpg
SELECT name, smlr FROM ( SELECT name, pattern <-> (SELECT pattern FROM pat WHERE name = 'C020_20180514_100234_R_CASIA2_LGC_000.jpg') AS smlr FROM pat WHERE name <> 'C020_20180514_100234_R_CASIA2_LGC_000.jpg' ORDER BY signature <-> (SELECT signature FROM pat WHERE name = 'C020_20180514_100234_R_CASIA2_LGC_000.jpg') LIMIT 100) x ORDER BY x.smlr ASC LIMIT 10;
搜索结果