ee.Array.bitCount

以元素為單位,計算輸入的 64 位元二補數二進位表示法中的 1 位元數。

用量傳回
Array.bitCount()陣列
引數類型詳細資料
這個:input陣列輸入陣列。

範例

程式碼編輯器 (JavaScript)

print(ee.Array([], ee.PixelType.int8()).bitCount());  // []

print(ee.Array([0]).bitCount());        // [0]
print(ee.Array([1]).bitCount());        // [1]
print(ee.Array([2]).bitCount());        // [1]
print(ee.Array([3]).bitCount());        // [2]
print(ee.Array([0xFFFF]).bitCount());   // [16]
print(ee.Array([1, 2, 3]).bitCount());  // [1,1,2]

print(ee.Array([[0, 1], [6, 13]]).bitCount());  // [[0,1],[2,3]]

// https://en.wikipedia.org/wiki/Two's_complement signed values.
print(ee.Array([-1]).bitCount());                       // [64]
print(ee.Array([-1], ee.PixelType.int8()).bitCount());  // [64]
print(ee.Array([-2]).bitCount());                       // [63]

Python 設定

請參閱 Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

display(ee.Array([], ee.PixelType.int8()).bitCount())  # []

display(ee.Array([0]).bitCount())        # [0]
display(ee.Array([1]).bitCount())        # [1]
display(ee.Array([2]).bitCount())        # [1]
display(ee.Array([3]).bitCount())        # [2]
display(ee.Array([0xFFFF]).bitCount())   # [16]
display(ee.Array([1, 2, 3]).bitCount())  # [1, 1, 2]

display(ee.Array([[0, 1], [6, 13]]).bitCount())  # [[0, 1], [2, 3]]

# https://en.wikipedia.org/wiki/Two's_complement signed values.
display(ee.Array([-1]).bitCount())                       # [64]
display(ee.Array([-1], ee.PixelType.int8()).bitCount())  # [64]
display(ee.Array([-2]).bitCount())                       # [63]