w, h = 100, 100
img = {getInt = function (x,y)
return x > 2 and x < 98 and y > 2 and y < 98 and -1 or
0
end}
ofs = 0
while ofs <= w/2 and ofs <= h/2 do
colors = {}
for y=ofs, h-ofs-1 do
colors[img.getInt(ofs, y)] = 1
colors[img.getInt(w-ofs-1, y)] = 1
end
for x=ofs, w-ofs-1 do
colors[img.getInt(x, ofs)] = 1
colors[img.getInt(x, h-ofs-1)] = 1
end
list, n = {}, 0
for color, _ in pairs(colors) do
n=n+1
list[n] = color
end
if #list > 1 then
return ofs == 0 and "no border found" or "border thickness: "..ofs
elseif lastcolor == nil then
lastcolor = list[1]
elseif lastcolor ~= list[1] then
return ofs == 0 and "no border found" or "border thickness: "..ofs
end
ofs = ofs+1
end
Bug description: Click "test run". Sometimes it returns "ndrder..." instead of "border...". Began life as a copy of #304
test run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Recognizer | Recognition Result | Visualize | Recalc |
|---|---|---|---|
| #308 | 795 | [visualize] |
| Snippet ID: | #305 |
| Snippet name: | Find border thickness bug test 2 |
| Eternal ID of this version: | #305/1 |
| Text MD5: | 56da9d081305b1b79c90916b9b39f4c6 |
| Author: | stefan |
| Category: | image recognition |
| Type: | Lua code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-01-04 19:50:33 |
| Source code size: | 795 bytes / 37 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1063 / 300 |
| Referenced in: | [show references] |