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

Comments [hide]

ID Author/Program Comment Date
627 #1000610 Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
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

}}
2015-08-19 01:14:41  delete 
625 #1000604 (pitcher) 2015-08-18 00:07:22

add comment

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: 1057 / 191
Referenced in: #373 - Maximize Contrast (also convert to black/white)
#503 - Convert image to 1 bit (threshold 50%)
#504 - Convert image to 1 bit (threshold 60%)
#505 - Convert image to 1 bit (threshold 55%)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)