Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

18
LINES

< > BotCompany Repo | #372 // Brightness range (contrast), embeddable

Lua code

get("#348") -- bright and rgb

function getContrast(img)
  
  local w, h = img.width, img.height
  local min, max = 1, 0

  for y = 0, h-1 do
    for x = 0, w-1 do
      local b = bright(rgb(img.getInt(x, y)))
      min, max = math.min(min, b), math.max(max, b)
    end
  end

  local minp = math.floor(min*100+0.5)
  local maxp = math.floor(max*100+0.5)
  return minp, maxp, min, max
end

Author comment

Began life as a copy of #371

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

2 comment(s) hidden. show

Snippet ID: #372
Snippet name: Brightness range (contrast), embeddable
Eternal ID of this version: #372/1
Text MD5: d9bb2f37d64d5385605e158ae1f09eea
Author: stefan
Category: feature extractor
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-01-31 23:55:30
Source code size: 407 bytes / 18 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1032 / 187
Referenced in: [show references]