diff --git a/src/Cod.ipynb b/src/Cod.ipynb
index 0cf54c6..d168e06 100644
--- a/src/Cod.ipynb
+++ b/src/Cod.ipynb
@@ -971,7 +971,7 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 35,
"id": "df358efa",
"metadata": {},
"outputs": [
@@ -1729,7 +1729,7 @@
"18 5 0 0 0.0 0.0 0.0 0.0 "
]
},
- "execution_count": 23,
+ "execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
@@ -1758,8 +1758,7 @@
"| `h0` | number of bits for each pixel (8 for greyscale, 24 for colour)? |\n",
"| `h1` | greyscale vs. colour? |\n",
"| `h9` | default depth of wavelet decomposition? |\n",
- "| `h10` | relative depth (to default) used for greyscale images, i.e., actual depth = `h9` - `h10`? |\n",
- "| `h36` to `h39` | relative depths for the individual colour components (although we would expect only three values not four)? |\n",
+ "| `h34` to `h39` | \"relative depths\" for the individual colour components (two for each?) |\n",
"\n",
"Given the depth *d*, the number of bands for one component (e.g., colour) is computed as *3d + 1*. So for the greyscale images, a depth of *5 - 1 = 4* would result in *3 * 4 + 1 = 13* bands which fits nicely to almost all of the greyscale images (24667 out of 24700).\n",
"\n",
@@ -1768,13 +1767,27 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 45,
"id": "dbccc5e2",
"metadata": {},
"outputs": [],
"source": [
- "def calc_bands(default_depth, y, b, r):\n",
- " return (default_depth - y) * 3 + 1 + (default_depth - b) * 3 + 1 + (default_depth - r) * 3 + 1 "
+ "from numpy import NaN\n",
+ "\n",
+ "def calc_band(default_depth, delta1, delta2):\n",
+ " \"\"\"Compute 3*(default_depth - delta1 - delta 2) + 1.\"\"\"\n",
+ " # Greyscale images have no value (NaN) for delta1 and delta2 for the colour compontents.\n",
+ " # To get a meaningful result, we replace both NaNs such that the result is 0:\n",
+ " # 3 * (default_depth - default_depth - 1/3) + 1 = 0\n",
+ " return (3 * (default_depth - delta1.fillna(default_depth) - delta2.fillna(1/3)) + 1).astype(int)\n",
+ "\n",
+ "def calc_bands(default_depth, y, yy, b, bb, r, rr):\n",
+ " \"\"\"Take a default depth and subtract the individual 'relative depths' for \n",
+ " each colour component. Why two values per colour component?\"\"\"\n",
+ " # Y' = luma\n",
+ " # Cb = blue difference\n",
+ " # Cr = red difference\n",
+ " return calc_band(default_depth, y, yy) + calc_band(default_depth, b, bb) + calc_band(default_depth, r, rr)"
]
},
{
@@ -1782,12 +1795,12 @@
"id": "194c6258",
"metadata": {},
"source": [
- "Let's take the values h36, h37, and h38 as relative depths for y, b, and r, respectively:"
+ "Let's take the values h34 to h39 as pairs of relative depths for y, b, and r, respectively:"
]
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 46,
"id": "250c120e",
"metadata": {},
"outputs": [
@@ -1857,8 +1870,8 @@
"
NaN | \n",
" NaN | \n",
" NaN | \n",
- " NaN | \n",
- " False | \n",
+ " 13 | \n",
+ " True | \n",
" \n",
" \n",
" 4426 | \n",
@@ -1881,7 +1894,7 @@
" NaN | \n",
" NaN | \n",
" NaN | \n",
- " NaN | \n",
+ " 13 | \n",
" False | \n",
"
\n",
" \n",
@@ -1905,8 +1918,8 @@
" NaN | \n",
" NaN | \n",
" NaN | \n",
- " NaN | \n",
- " False | \n",
+ " 16 | \n",
+ " True | \n",
"
\n",
" \n",
" 13 | \n",
@@ -1929,8 +1942,8 @@
" NaN | \n",
" NaN | \n",
" NaN | \n",
- " NaN | \n",
- " False | \n",
+ " 16 | \n",
+ " True | \n",
"
\n",
" \n",
" 2 | \n",
@@ -1953,7 +1966,7 @@
" 0.0 | \n",
" 4.0 | \n",
" 0.0 | \n",
- " 27.0 | \n",
+ " 27 | \n",
" True | \n",
"
\n",
" \n",
@@ -1977,7 +1990,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 30.0 | \n",
+ " 30 | \n",
" True | \n",
"
\n",
" \n",
@@ -2001,7 +2014,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 30.0 | \n",
+ " 30 | \n",
" True | \n",
"
\n",
" \n",
@@ -2025,7 +2038,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 30.0 | \n",
+ " 30 | \n",
" True | \n",
"
\n",
" \n",
@@ -2049,8 +2062,8 @@
" 1.0 | \n",
" 2.0 | \n",
" 1.0 | \n",
- " 33.0 | \n",
- " False | \n",
+ " 30 | \n",
+ " True | \n",
"
\n",
" \n",
" 11 | \n",
@@ -2073,7 +2086,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 30.0 | \n",
+ " 30 | \n",
" True | \n",
"
\n",
" \n",
@@ -2097,7 +2110,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 30.0 | \n",
+ " 30 | \n",
" True | \n",
"
\n",
" \n",
@@ -2121,7 +2134,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 30.0 | \n",
+ " 30 | \n",
" True | \n",
"
\n",
" \n",
@@ -2145,7 +2158,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 30.0 | \n",
+ " 30 | \n",
" True | \n",
"
\n",
" \n",
@@ -2169,7 +2182,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 30.0 | \n",
+ " 30 | \n",
" True | \n",
"
\n",
" \n",
@@ -2193,7 +2206,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 30.0 | \n",
+ " 30 | \n",
" True | \n",
"
\n",
" \n",
@@ -2217,7 +2230,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 33.0 | \n",
+ " 33 | \n",
" True | \n",
"
\n",
" \n",
@@ -2241,8 +2254,8 @@
" 1.0 | \n",
" 2.0 | \n",
" 1.0 | \n",
- " 36.0 | \n",
- " False | \n",
+ " 33 | \n",
+ " True | \n",
"
\n",
" \n",
" 7 | \n",
@@ -2265,7 +2278,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 33.0 | \n",
+ " 33 | \n",
" True | \n",
"
\n",
" \n",
@@ -2289,7 +2302,7 @@
" 0.0 | \n",
" 3.0 | \n",
" 0.0 | \n",
- " 33.0 | \n",
+ " 33 | \n",
" True | \n",
"
\n",
" \n",
@@ -2313,7 +2326,7 @@
" 0.0 | \n",
" 2.0 | \n",
" 0.0 | \n",
- " 36.0 | \n",
+ " 36 | \n",
" True | \n",
"
\n",
" \n",
@@ -2337,7 +2350,7 @@
" 0.0 | \n",
" 2.0 | \n",
" 0.0 | \n",
- " 36.0 | \n",
+ " 36 | \n",
" True | \n",
"
\n",
" \n",
@@ -2361,7 +2374,7 @@
" 0.0 | \n",
" 2.0 | \n",
" 0.0 | \n",
- " 36.0 | \n",
+ " 36 | \n",
" True | \n",
"
\n",
" \n",
@@ -2385,7 +2398,7 @@
" 0.0 | \n",
" 2.0 | \n",
" 0.0 | \n",
- " 36.0 | \n",
+ " 36 | \n",
" False | \n",
"
\n",
" \n",
@@ -2409,7 +2422,7 @@
" 0.0 | \n",
" 2.0 | \n",
" 0.0 | \n",
- " 39.0 | \n",
+ " 39 | \n",
" True | \n",
"
\n",
" \n",
@@ -2433,7 +2446,7 @@
" 0.0 | \n",
" 2.0 | \n",
" 0.0 | \n",
- " 39.0 | \n",
+ " 39 | \n",
" True | \n",
"
\n",
" \n",
@@ -2457,7 +2470,7 @@
" 0.0 | \n",
" 2.0 | \n",
" 0.0 | \n",
- " 39.0 | \n",
+ " 39 | \n",
" True | \n",
"
\n",
" \n",
@@ -2481,7 +2494,7 @@
" 0.0 | \n",
" 1.0 | \n",
" 0.0 | \n",
- " 42.0 | \n",
+ " 42 | \n",
" True | \n",
"
\n",
" \n",
@@ -2505,7 +2518,7 @@
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
- " 48.0 | \n",
+ " 48 | \n",
" True | \n",
"
\n",
" \n",
@@ -2545,45 +2558,45 @@
"18 zoom0 250 250 48 24 1 0 0 1 1 ... 1 5 \n",
"\n",
" h34 h35 h36 h37 h38 h39 bands' b == b'? \n",
- "2447 1 0 NaN NaN NaN NaN NaN False \n",
- "4426 1 0 NaN NaN NaN NaN NaN False \n",
- "12 0 0 NaN NaN NaN NaN NaN False \n",
- "13 0 0 NaN NaN NaN NaN NaN False \n",
- "2 0 0 3.0 0.0 4.0 0.0 27.0 True \n",
- "15 0 0 3.0 0.0 3.0 0.0 30.0 True \n",
- "17 0 0 3.0 0.0 3.0 0.0 30.0 True \n",
- "16 0 0 3.0 0.0 3.0 0.0 30.0 True \n",
- "14 0 0 2.0 1.0 2.0 1.0 33.0 False \n",
- "11 0 0 3.0 0.0 3.0 0.0 30.0 True \n",
- "0 0 0 3.0 0.0 3.0 0.0 30.0 True \n",
- "9 0 0 3.0 0.0 3.0 0.0 30.0 True \n",
- "6 0 0 3.0 0.0 3.0 0.0 30.0 True \n",
- "5 0 0 3.0 0.0 3.0 0.0 30.0 True \n",
- "10 0 0 3.0 0.0 3.0 0.0 30.0 True \n",
- "8 0 0 2.0 0.0 3.0 0.0 33.0 True \n",
- "1 0 0 1.0 1.0 2.0 1.0 36.0 False \n",
- "7 0 0 2.0 0.0 3.0 0.0 33.0 True \n",
- "3 0 0 2.0 0.0 3.0 0.0 33.0 True \n",
- "207 0 0 2.0 0.0 2.0 0.0 36.0 True \n",
- "38 0 0 2.0 0.0 2.0 0.0 36.0 True \n",
- "4 0 0 2.0 0.0 2.0 0.0 36.0 True \n",
- "1019 0 0 2.0 0.0 2.0 0.0 36.0 False \n",
- "147 0 0 1.0 0.0 2.0 0.0 39.0 True \n",
- "520 0 0 1.0 0.0 2.0 0.0 39.0 True \n",
- "19 0 0 1.0 0.0 2.0 0.0 39.0 True \n",
- "22 0 0 1.0 0.0 1.0 0.0 42.0 True \n",
- "18 0 0 0.0 0.0 0.0 0.0 48.0 True \n",
+ "2447 1 0 NaN NaN NaN NaN 13 True \n",
+ "4426 1 0 NaN NaN NaN NaN 13 False \n",
+ "12 0 0 NaN NaN NaN NaN 16 True \n",
+ "13 0 0 NaN NaN NaN NaN 16 True \n",
+ "2 0 0 3.0 0.0 4.0 0.0 27 True \n",
+ "15 0 0 3.0 0.0 3.0 0.0 30 True \n",
+ "17 0 0 3.0 0.0 3.0 0.0 30 True \n",
+ "16 0 0 3.0 0.0 3.0 0.0 30 True \n",
+ "14 0 0 2.0 1.0 2.0 1.0 30 True \n",
+ "11 0 0 3.0 0.0 3.0 0.0 30 True \n",
+ "0 0 0 3.0 0.0 3.0 0.0 30 True \n",
+ "9 0 0 3.0 0.0 3.0 0.0 30 True \n",
+ "6 0 0 3.0 0.0 3.0 0.0 30 True \n",
+ "5 0 0 3.0 0.0 3.0 0.0 30 True \n",
+ "10 0 0 3.0 0.0 3.0 0.0 30 True \n",
+ "8 0 0 2.0 0.0 3.0 0.0 33 True \n",
+ "1 0 0 1.0 1.0 2.0 1.0 33 True \n",
+ "7 0 0 2.0 0.0 3.0 0.0 33 True \n",
+ "3 0 0 2.0 0.0 3.0 0.0 33 True \n",
+ "207 0 0 2.0 0.0 2.0 0.0 36 True \n",
+ "38 0 0 2.0 0.0 2.0 0.0 36 True \n",
+ "4 0 0 2.0 0.0 2.0 0.0 36 True \n",
+ "1019 0 0 2.0 0.0 2.0 0.0 36 False \n",
+ "147 0 0 1.0 0.0 2.0 0.0 39 True \n",
+ "520 0 0 1.0 0.0 2.0 0.0 39 True \n",
+ "19 0 0 1.0 0.0 2.0 0.0 39 True \n",
+ "22 0 0 1.0 0.0 1.0 0.0 42 True \n",
+ "18 0 0 0.0 0.0 0.0 0.0 48 True \n",
"\n",
"[28 rows x 22 columns]"
]
},
- "execution_count": 25,
+ "execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "dfa[\"bands'\"] = calc_bands(df[\"h9\"], df[\"h36\"], df[\"h37\"], df[\"h38\"])\n",
+ "dfa[\"bands'\"] = calc_bands(dfa.h9, dfa.h34, dfa.h35, dfa.h36, dfa.h37, dfa.h38, dfa.h39)\n",
"dfa[\"b == b'?\"] = dfa[\"bands\"] == dfa[\"bands'\"]\n",
"dfa"
]
@@ -2593,7 +2606,7 @@
"id": "78290f2e",
"metadata": {},
"source": [
- "The computed number of bands fits nicely for almost all colour tiles, except only one (!) zoom2 tile with 37 bands. The \"fox\" and \"wolf\" example images are the only ones that have a non-zero value for `h39` and the number of computed bands is too large by 3 for each of them. So maybe the 1 in `h39` tells us to reduce the number of bands by 3 – but why? "
+ "The computed number of bands fits nicely for almost all colour tiles, except only one (!) zoom2 tile with 37 bands. The \"fox\" and \"wolf\" example images are the only ones that have non-zero values for `h37` and `h39`, thus requiring these two \"extra\" relative depths. Would be interesting to know what they mean."
]
},
{