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

9
LINES

< > BotCompany Repo | #1033305 // rgbToLuminosity

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3846L/22K).

// allegedly the best method for rgb to grayscale conversion:
// Z=0.2126×R+0.7152G+0.0722B

static int rgbToLuminosity(int rgb) {
  int r = (rgb >> 16) & 0xFF;
  int g = (rgb >> 8) & 0xFF;
  int b = rgb & 0xFF;
  ret iround(r*0.2126+g*0.7152+b*0.0722);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033305
Snippet name: rgbToLuminosity
Eternal ID of this version: #1033305/2
Text MD5: f15d78746eca744e444dc9e00aea548f
Transpilation MD5: 24aaa965e17f696c8d499e91b070a4fe
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-21 01:14:25
Source code size: 266 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 153 / 224
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)