python-visualization / python-visualization/branca
Is it normal for `branca.utilities.write_png` function to normalize its values?
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 134
- フォーク
- 69
- 平均マージ
- 1時間 10分
- マージ済み PR(30日)
- 1
説明
I may be wrong, but I find it weird the way branca.utilities.write_png function normalize its values.
See https://github.com/python-visualization/branca/blob/v0.8.1/branca/utilities.py#L324.
>>> import io
>>>
>>> import numpy as np
>>> import PIL.Image
>>>
>>> import branca.utilities
>>>
>>> data = np.array([[[0.74901961, 0.50196078, 1.0, 1.0], [0.25098039, 1.0, 0.74901961, 1.0]]])
>>>
>>> # Current result
>>> png_bytes = branca.utilities.write_png(data)
>>> with PIL.Image.open(io.BytesIO(png_bytes)) as image:
... np.asarray(image)
array([[[255, 127, 255, 255],
[ 85, 255, 191, 255]]], dtype=uint8)
>>>
>>> # What I expected
>>> np.rint(data * 255.0).astype(np.uint8)
array([[[191, 128, 255, 255],
[ 64, 255, 191, 255]]], dtype=uint8)
As a result, folium layers like folium.raster_layers.ImageOverlay appear brighter than I expected when passing image as an array because of the normalization.
I guess this allows users to automatically display mono rasters with a scale from minimum value as black to maximum value as white. However, for non-mono and mono rasters with a colormap, the normalization seems undesirable.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
branca/utilities.py の write_png から始め、リンクされた行と提供された NumPy/PIL の例を使って現在の出力を再現します。完了条件は、モノ、非モノ、カラーマップ付きのラスターについて意図された正規化の挙動を決定して検証することです。これには folium の ImageOverlay レイヤーで報告されている明るさへの影響も含まれます。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- numpy, python
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100