optimize, which probably doesnt improve
This commit is contained in:
@@ -10,7 +10,7 @@ from imagelist2.db import DB, sqlite_sqrt, sqlite_square
|
||||
from imagelist2.image import ImageMeasure, is_image_extension
|
||||
from tqdm import tqdm
|
||||
|
||||
__version__ = "0.0.4"
|
||||
__version__ = "0.0.5"
|
||||
SQLFILE = "image-list.sqlite"
|
||||
# IMGMATCH = re.compile("|".join([".*\." + x + "$" |.*\.jpeg$|.*\.png$|.*\.gif$|.*\.tif$", re.I)
|
||||
BADDIRS = ["_tn", "_med", ".tn", ".med"]
|
||||
@@ -505,14 +505,20 @@ class ImageList:
|
||||
t2.height AS height2,
|
||||
t2.sharpness AS sharpness2,
|
||||
PDISTANCE(t1.p_hash,t2.p_hash) AS p_distance,
|
||||
COLORDIFF(t1.R,t1.G,t1.B,t2.R,t2.G,t2.B) AS c_diff,
|
||||
SHAPEDIFF(t1.width,t1.height,t2.width,t2.height) AS s_diff
|
||||
t1.R AS t1r, t1.G AS t1g, t1.B AS t1b,
|
||||
t2.R AS t2r, t2.G AS t2g, t2.B AS t2b
|
||||
FROM t1 INNER JOIN t2
|
||||
ON t1.file < t2.file
|
||||
WHERE p_distance <= ?
|
||||
ORDER BY t1.file, p_distance, t2.file
|
||||
)
|
||||
SELECT * FROM disttab
|
||||
SELECT
|
||||
file1,width1,height1,sharpness1,
|
||||
file2,width2,height2,sharpness2,
|
||||
p_distance,
|
||||
ROUND(SQRT((t1r-t2r)*(t1r-t2r)+(t1g-t2g)*(t1g-t2g)+(t1b-t2b)*(t1b-t2b)),1) AS c_diff,
|
||||
ROUND(ABS((CAST(width1 AS FLOAT) / CAST(height1 AS FLOAT)) - (CAST(width2 AS FLOAT) / CAST(height2 AS FLOAT))), 4) AS s_diff
|
||||
FROM disttab
|
||||
""",
|
||||
(thr,),
|
||||
)
|
||||
|
||||
@@ -58,6 +58,7 @@ class DB:
|
||||
def connect(self):
|
||||
conn = sqlite3.connect(self.sqlfile)
|
||||
conn.text_factory = str
|
||||
conn.create_function("SQRT", 1, sqlite_sqrt)
|
||||
conn.create_function("RELATIVE", 1, self.file2relative)
|
||||
conn.create_function("PDISTANCE", 2, calculate_phash_distance)
|
||||
conn.create_function("COLORDIFF", 6, calculate_color_difference)
|
||||
|
||||
Reference in New Issue
Block a user