2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JavaScriptでユークリッド色差計算

Last updated at Posted at 2017-02-09

Color difference(wikipedia)で公開されているユークリッドの色差計算式をJavaScriptで書いてみました。

wikipediaで公開されている計算式は以下のとおりです。

Euclidean
(「Color difference」(5 Feb 2017, at 02:30. UTC)『ウィキペディア』より引用)

この計算式は知らない記号もなくシンプルなので、そのまま書くことができます。

euclidean
function euclidean(r1,g1,b1, r2,g2,b2) {
	return Math.sqrt(
			Math.pow(r2 - r1, 2) + 
			Math.pow(g2 - g1, 2) +
			Math.pow(b2 - b1, 2)
			);
}

関連リンク

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?