get("#348") -- bright and rgb maxLen = 20 -- maximum sensible length of signature -- from Java class "SegmentCounter" function countSegments(y, flip) local lastPix = 1 local segments = 0 for x = 0, (flip and h or w)-1 do local pix = bright(rgb(flip and img.getInt(y, x) or img.getInt(x, y))) if pix >= brightnessThreshold and lastPix < brightnessThreshold then segments = segments+1 end lastPix = pix end if lastPix < brightnessThreshold then segments = segments+1 end return segments end function getSegmentCount(flip) local s = "" local lastN = 0 for y = 0, (flip and w or h)-1 do local n = math.min(countSegments(y, flip), 9) if n ~= lastN then s = s..n if #s > maxLen then return end end lastN = n end if lastN == 0 and #s > 0 then return s:sub(1, #s-1) else return s end end w, h = img.width, img.height brightnessThreshold = 0.9 s = getSegmentCount(true) if s then return "Horizontal signature: "..s end