1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-12 17:26:23 +00:00

adjust webtoon edge detection threshold

This commit is contained in:
Alex Xu
2025-10-16 22:47:37 -07:00
parent e2b98db1a2
commit d28740491e

View File

@@ -103,8 +103,8 @@ def splitImage(work):
Image.MAX_IMAGE_PIXELS = 1000000000
imgOrg = Image.open(filePath).convert('RGB')
imgEdges = Image.open(filePath).convert('L').filter(ImageFilter.FIND_EDGES)
# the threshold of 8 is conservative. 0-6 are definitely not edges
imgProcess = imgEdges.point(lambda p: 255 if p > 8 else 0).convert('1', dither=Dither.NONE)
# threshold of 8 is too high. 5 is too low.
imgProcess = imgEdges.point(lambda p: 255 if p > 6 else 0).convert('1', dither=Dither.NONE)
widthImg, heightImg = imgOrg.size
if heightImg > opt.height:
@@ -117,7 +117,8 @@ def splitImage(work):
panelDetected = False
panels = []
while yWork < heightImg:
tmpImg = imgProcess.crop((4, yWork, widthImg-4, yWork + 4))
edge = int(widthImg * .05)
tmpImg = imgProcess.crop((edge, yWork, widthImg-edge, yWork + 4))
solid = detectSolid(tmpImg)
if not solid and not panelDetected:
panelDetected = True