mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
adjust webtoon edge detection threshold
This commit is contained in:
@@ -103,8 +103,8 @@ def splitImage(work):
|
|||||||
Image.MAX_IMAGE_PIXELS = 1000000000
|
Image.MAX_IMAGE_PIXELS = 1000000000
|
||||||
imgOrg = Image.open(filePath).convert('RGB')
|
imgOrg = Image.open(filePath).convert('RGB')
|
||||||
imgEdges = Image.open(filePath).convert('L').filter(ImageFilter.FIND_EDGES)
|
imgEdges = Image.open(filePath).convert('L').filter(ImageFilter.FIND_EDGES)
|
||||||
# the threshold of 8 is conservative. 0-6 are definitely not edges
|
# threshold of 8 is too high. 5 is too low.
|
||||||
imgProcess = imgEdges.point(lambda p: 255 if p > 8 else 0).convert('1', dither=Dither.NONE)
|
imgProcess = imgEdges.point(lambda p: 255 if p > 6 else 0).convert('1', dither=Dither.NONE)
|
||||||
|
|
||||||
widthImg, heightImg = imgOrg.size
|
widthImg, heightImg = imgOrg.size
|
||||||
if heightImg > opt.height:
|
if heightImg > opt.height:
|
||||||
@@ -117,7 +117,8 @@ def splitImage(work):
|
|||||||
panelDetected = False
|
panelDetected = False
|
||||||
panels = []
|
panels = []
|
||||||
while yWork < heightImg:
|
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)
|
solid = detectSolid(tmpImg)
|
||||||
if not solid and not panelDetected:
|
if not solid and not panelDetected:
|
||||||
panelDetected = True
|
panelDetected = True
|
||||||
|
|||||||
Reference in New Issue
Block a user