# Reconstructing Binary Signals from Local Histograms

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Metameric Signal Classes

## 3. An Algorithm for Reconstructing the Complete Set of Signals from a Sequence of Histograms

- Fact 1
- There is a non-empty and finite set of signals of size m, which share the same histogram h. These can be produced as all the distinct permutations of the following signal:$$S=[\underset{h\left(0\right)}{\underset{\u23df}{0;\dots ;0}};\underset{h\left(1\right)}{\underset{\u23df}{1;\dots ;1}}],$$$$\left(\genfrac{}{}{0pt}{}{h\left(0\right)+h\left(1\right)}{h\left(0\right)}\right)=\frac{\left(h\left(0\right)+h\left(1\right)\right)!}{h\left(0\right)!h\left(1\right)!};$$
- Fact 2
- Consider the windows ${S}_{i-1}$ and ${S}_{i}$ and their corresponding histograms ${h}_{i-1}$ and ${h}_{i}$ for $i=0..n-m$. If ${s}_{i-1}={s}_{i+m-1}$, the histograms will be identical; otherwise, the histograms will differ by the count of one at ${s}_{i-1}$ and at ${s}_{i+m-1}$, and ${s}_{i+m-1}={\overline{s}}_{i-1}$, where $\overline{\xb7}$ is the Boolean “not” operator;
- Fact 3
- From Fact 2, it follows that the histogram of $[{s}_{i};{s}_{i+1};\dots ;{s}_{i+m-2}]$ is equal to ${h}_{i}$, but where ${h}_{i}\left({s}_{i+m-1}\right)$ has been reduced by one. We call this ${h}_{i}^{\prime}$;
- Fact 4
- The difference,$${d}_{i}\left(a\right)={h}_{i-1}\left(a\right)-{h}_{i}^{\prime}\left(a\right)=\left\{\begin{array}{c}1,\phantom{\rule{4.pt}{0ex}}\mathrm{when}\phantom{\rule{4.pt}{0ex}}a={s}_{i-1},\hfill \\ 0,\phantom{\rule{4.pt}{0ex}}\mathrm{otherwise}.\hfill \end{array}\right.$$As a consequence, for candidate signals ${S}_{i}^{\prime}$ that have histogram ${h}_{i}$, but that have the wrong value placed at ${s}_{i+m-1}$, the difference will have both negative and positive values.

- Step 1
- Produce a candidate set of all the distinct signals of size m that have the histogram ${h}_{n-m}$;
- Step 2
- For $i=n-m-1$ …0 and for each element in the candidate set ${S}_{i}$:
- Step 2.1
- Calculate ${d}_{i}$.
- Step 2.2
- If ${d}_{i}$ does not have the form of (22), then discard it;
- Step 2.3
- Else, derive ${s}_{i-1}$ from ${d}_{i}$, and extend the candidate with this value:

https://github.com/sporring/reconstructionFromHistograms/reconstructionFromHistograms.fsx. For the specific version discussed in this paper, see the commit of 24 December 2021, https://github.com/sporring/reconstructionFromHistograms/commit/333506e72fd8bea2132857869aca15b54392aa75 (accessed on 24 December 2021).

signal: int list = [0; 1; 0; 1; 1],

histogramList: Map<int,int> list = [map [(0, 2); (1, 1)]; map [(0, 1); (1, 2)]; map [(0, 1); (1, 2)]],

solutions: int list list = [[0; 0; 1; 1; 0]; [0; 1; 0; 1; 1]].

## 4. Theoretical Considerations on $\mathbf{\mu}$ and $\mathbf{\kappa}$

#### 4.1. Constant Sequence of Histograms (${h}_{0}={h}_{j}$)

#### 4.2. Global Histogram ($m=n$)

#### 4.3. Smallest Histogram ($m=2$)

#### 4.4. The General Case ($n>m>2$)

- Fact 5
- $({\sigma}_{j},{\sigma}_{j+1})$ is a tridiagonal table: Since ${\sigma}_{j}$ and ${\sigma}_{j+1}$ only differ by the values ${s}_{j}$ and ${s}_{j+m}$, then the differences between ${\sigma}_{j}$ and ${\sigma}_{j+1}$ can maximally be one. Hence, the table will have a tridiagonal structure;
- Fact 6
- Elements on the main diagonal have ${s}_{j}={s}_{j+m}$: On the diagonal ${\sigma}_{j+1}={\sigma}_{j}$, hence:$$\begin{array}{cc}\hfill {\sigma}_{j}& =\sum _{i=0}^{m-1}{s}_{j+i}={s}_{j}+\sum _{i=1}^{m-1}{s}_{j+i}\hfill \end{array}$$$$\begin{array}{cc}\hfill {\sigma}_{j+1}& =\sum _{i=0}^{m-1}{s}_{j+1+i}={s}_{j+m}+\sum _{i=0}^{m-2}{s}_{j+1+i}={s}_{j+m}+\sum _{i=1}^{m-1}{s}_{j+i}={\sigma}_{j}\hfill \end{array}$$Thus, ${s}_{j}={s}_{j+m}$;
- Fact 7
- Elements on the first diagonal above have ${s}_{j}=0\wedge {s}_{j+m}=1$: On the first diagonal above, ${\sigma}_{j+1}={\sigma}_{j}+1$, and thus,$$\begin{array}{cc}\hfill {\sigma}_{j}& ={s}_{j}+\sum _{i=1}^{m-1}{s}_{j+i}\hfill \end{array}$$$$\begin{array}{cc}\hfill {\sigma}_{j+1}& ={s}_{j+m}+\sum _{i=1}^{m-1}{s}_{j+i}={\sigma}_{j}+1\hfill \end{array}$$Thus, ${s}_{j}={s}_{j+m}-1\Rightarrow {s}_{j}=0\wedge {s}_{j+m}=1$;
- Fact 8
- Elements the first diagonal below have ${s}_{j}=1\wedge {s}_{j+m}=0$: On the first diagonal below, ${\sigma}_{j+1}={\sigma}_{j}-1$, and thus,$$\begin{array}{cc}\hfill {\sigma}_{j}& ={s}_{j}+\sum _{i=1}^{m-1}{s}_{j+i}\hfill \end{array}$$$$\begin{array}{cc}\hfill {\sigma}_{j+1}& ={s}_{j+m}+\sum _{i=1}^{m-1}{s}_{j+i}={\sigma}_{j}-1\hfill \end{array}$$Thus, ${s}_{j}={s}_{j+m}+1\Rightarrow {s}_{j}=1\wedge {s}_{j+m}=0$.

- Fact 9
- For $({\sigma}_{j}^{\prime},{\sigma}_{j+1}^{\prime})\in \{(0,0),(1,0),(0,1),(m,m),(m-1,m),(m,m-1)\}$,$$\gamma ({\sigma}_{j}^{\prime},{\sigma}_{j+1}^{\prime})=1:$$In all six cases, the histograms are from signals where either or both ${S}_{j}$ and ${S}_{j+1}$ are constant, and hence, we can trivially reconstruct the corresponding $m+1$ values from the histograms. We call such a histogram pair a two-trivial pair;
- Fact 10
- On the main diagonal, except ${\sigma}_{j}={\sigma}_{j+1}=0$ and ${\sigma}_{j}={\sigma}_{j+1}=m$,$$\gamma ({\sigma}_{j},{\sigma}_{j})=\left(\genfrac{}{}{0pt}{}{m-1}{{\sigma}_{j}}\right)+\left(\genfrac{}{}{0pt}{}{m-1}{{\sigma}_{j}-1}\right):$$By Fact 6, ${s}_{j}={s}_{j+m}$. For ${s}_{j}=0$, the possible signals for ${s}_{j+k},1\le k\le m-1$ are signals summing to ${\sigma}_{j}$, i.e., $\left(\genfrac{}{}{0pt}{}{m-1}{{\sigma}_{j}}\right)$, and for ${s}_{j}=1$, we have $\left(\genfrac{}{}{0pt}{}{m-1}{{\sigma}_{j}-1}\right)$. Since $0<{\sigma}_{j}<m$, therefore $\gamma ({\sigma}_{j},{\sigma}_{j})\ge 2$;
- Fact 11
- On the first diagonal above,$$\gamma ({\sigma}_{j},{\sigma}_{j}+1)=\left(\genfrac{}{}{0pt}{}{m-1}{{\sigma}_{j}}\right):$$By Fact 7, ${s}_{j}=0\wedge {s}_{j+m}=1$. Hence, the possible signals for ${s}_{j+i},1\le i\le m-1$ are signals summing to ${\sigma}_{j}$. Further, since $1<{\sigma}_{j+1}<m$ and ${\sigma}_{j+1}={\sigma}_{j}+1$, therefore $0<{\sigma}_{j}<m-1$, and therefore, $\gamma (0,{\sigma}_{j}+1)=\gamma (m-1,{\sigma}_{j}+1)=1$ and $\gamma ({\sigma}_{j},{\sigma}_{j}+1)\ge 2$ for all other cases;
- Fact 12
- On the first diagonal below,$$\gamma ({\sigma}_{j},{\sigma}_{j}-1)=\left(\genfrac{}{}{0pt}{}{m-1}{{\sigma}_{j+1}}\right):$$By Fact 8, ${s}_{j}=1\wedge {s}_{j+m}=0$. Hence, the possible signals for ${s}_{j+i},1\le i\le m-1$ are signals summing to ${\sigma}_{j}-1={\sigma}_{j+1}$. Further, since $1<{\sigma}_{j}<m$ and ${\sigma}_{j+1}={\sigma}_{j}-1$, then $0<{\sigma}_{j+1}<m-1$, and therefore, $\gamma ({\sigma}_{j},0)=\gamma ({\sigma}_{j},m-1)=1$ and $\gamma ({\sigma}_{j},{\sigma}_{j}-1)\ge 2$ in all other cases.

- Fact 13
- Any signal of any length $n>2,m=2$ can be described as a route following the arrows in the table;
- Fact 14
- An element in column j transitions to an element in row j, and as a consequence,$$\begin{array}{cc}\hfill ({\sigma}_{j},{\sigma}_{j})& \to ({\sigma}_{j},{\sigma}_{k})\phantom{\rule{2.em}{0ex}}(\mathrm{horizontal}\phantom{\rule{4.pt}{0ex}}\mathrm{motion}),\hfill \end{array}$$$$\begin{array}{cc}\hfill ({\sigma}_{j},{\sigma}_{j+1})& \to ({\sigma}_{j+1},{\sigma}_{k})\phantom{\rule{2.em}{0ex}}\phantom{\rule{-9.95845pt}{0ex}}(\mathrm{down}\phantom{\rule{4.pt}{0ex}}\mathrm{motion}),\hfill \end{array}$$$$\begin{array}{cc}\hfill ({\sigma}_{j+1},{\sigma}_{j})& \to ({\sigma}_{j},{\sigma}_{k})\phantom{\rule{2.em}{0ex}}(\mathrm{up}\phantom{\rule{4.pt}{0ex}}\mathrm{motion}),\hfill \end{array}$$
- Fact 15
- Any entry is maximally $m-1$ steps away from a two-trivial element, since starting at element $[{s}_{0},\dots ,{s}_{m-2},{s}_{m}]$, there is an $m-1$ path leading to $[{s}_{m-2},{s}_{m},\dots ,{s}_{m}]$.

- Fact 16
- Intracellular paths for $0<i,j<m+1,|j-i|\le 1$, are ambiguous, since these cells contain several indistinguishable elements, and we cannot determine the path’s starting point from its histogram sequence;
- Fact 17
- Cell pairs, connected by more than one arrow in the same direction, give rise to ambiguous pairs, and paths that only contain such crossings or intracellular paths are ambiguous, since the paths cannot be distinguished by their histograms;
- Fact 18
- For $m=n-1$, the number of metameric classes is equal to the number of non-empty cells in the tridiagonal table minus the six two-trivial cells.$$\kappa (2,n,n-1)=n+2(n-1)-6=3n-8.$$For $2\le m<n-1$, an upper bound on the number of metameric classes is equal to the number of ambiguous paths. We have yet to come up with a closed form for $\kappa (n,m)$.

## 5. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## References

- Koenderink, J.J.; Doorn, A.J.V. The Structure of Locally Orderless Images. Int. J. Comput. Vis.
**1999**, 31, 159–168. [Google Scholar] [CrossRef] - MacWilliams, F.; Sloane, N. The Theory of Error-Correcting Codes; Bell Laboratories: Holmdel, NJ, USA, 1977. [Google Scholar]
- Lillholm, M.; Nielsen, M.; Griffin, L.D. Feature-Based Image Analysis. Int. J. Comput. Vis.
**2003**, 52, 73–95. [Google Scholar] [CrossRef] - Weinzaepfel, P.; Jégou, H.; Pérez, P. Reconstructing an image from its local descriptors. In Proceedings of the CVPR 2011, Colorado Springs, CO, USA, 20–25 June 2011; pp. 337–344. [Google Scholar]
- Lowe, D.G. Object Recognition from Local Scale-Invariant Features. In Proceedings of the Seventh IEEE International Conference on Computer Vision, Kerkyra, Greece, 20–27 September 1999. [Google Scholar]
- D’Angelo, E.; Jacques, L.; Alahi, A.; Vandergheynst, P. From bits to images: Inversion of local binary descriptors. IEEE Trans. Pattern Anal. Mach. Intell.
**2014**, 36, 874–887. [Google Scholar] [CrossRef] [PubMed][Green Version] - Kato, H.; Harada, T. Image Reconstruction from Bag-of-Visual-Words. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Columbus, OH, USA, 23–28 June 2014. [Google Scholar]
- Desolneux, A.; Leclaire, A. Stochastic Image Reconstruction from Local Histograms of Gradient Orientation. In Proceedings of the International Conference on Scale Space and Variational Methods in Computer Vision, Kolding, Denmark, 4–8 June 2017; Lauze, F., Dong, Y., Dahl, A.B., Eds.; Springer International Publishing: Cham, Switzerland, 2017; Volume 10302, pp. 133–145. [Google Scholar]
- Dosovitskiy, A.; Brox, T. Inverting Visual Representations with Convolutional Networks. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, 27–30 June 2016; pp. 4829–4837. [Google Scholar]
- Krizhevsky, A.; Sutskever, I.; Hinton, G.E. ImageNet classification with deep convolutional neural networks. Commun. ACM
**2012**, 60, 84–90. [Google Scholar] [CrossRef] - Wu, H.; Zhou, J.; Li, Y. Image Reconstruction from Local Descriptors Using Conditional Adversarial Networks. In Proceedings of the 2019 Asia-Pacific Signal and Information Processing Association Annual Summit and Conference (APSIPA ASC), Lanzhou, China, 18–21 November 2019. [Google Scholar]
- Wu, Y.N.; Zhu, S.C.; Liu, X. Equivalence of Julesz Ensembles and FRAME Models. Int. J. Comput. Vis.
**2000**, 38, 247–265. [Google Scholar] [CrossRef] - Zhu, S.C.; Wu, Y.; Mumford, D. Filters, Random Fields and Maximum Entropy (FRAME): Towards a Unified Theory for Texture Modeling. Int. J. Comput. Vis.
**1998**, 27, 107–126. [Google Scholar] [CrossRef][Green Version] - Julesz, B. Visual Pattern Discrimination. IRE Trans. Inf. Theory
**1962**, 8, 84–92. [Google Scholar] [CrossRef] - Gabor, D. Theory of communication. Part 1: The analysis of information. J. Inst. Electr. Eng. Part III Radio Commun. Eng.
**1946**, 93, 429–441. [Google Scholar] [CrossRef][Green Version]

**Figure 1.**Local, overlapping histograms are calculated from a signal. Does the set of histograms uniquely identify a signal?

**Figure 2.**The reconstruction of the signal from a stream of local histograms. If the current point in the sequence can be resolved, the complete signal up until this point can be resolved.

**Table 1.**For different signal (n) and window (m) sizes, we calculated the total number of different signals (${2}^{n}$), the number of signals not belonging to a metameric class, i.e., invertible ($\mu $), and the number of different metameric classes ($\kappa $).

n | 2 | 3 | 3 | 4 | 4 | 4 | 5 | 5 | 5 | 5 | 6 | 6 | 6 | 6 | 6 |

m | 2 | 2 | 3 | 2 | 3 | 4 | 2 | 3 | 4 | 5 | 2 | 3 | 4 | 5 | 6 |

${2}^{n}$ | 4 | 8 | 8 | 16 | 16 | 16 | 32 | 32 | 32 | 32 | 64 | 64 | 64 | 64 | 64 |

$\mu $ | 2 | 6 | 2 | 14 | 6 | 2 | 30 | 18 | 6 | 2 | 62 | 46 | 18 | 6 | 2 |

$\kappa $ | 1 | 1 | 2 | 1 | 4 | 3 | 1 | 6 | 7 | 4 | 1 | 8 | 15 | 10 | 5 |

**Table 2.**All signals grouped by the sum of their local histograms when $n=3$ and $m=2$. Arrows show the relations between the $({\sigma}_{j},{\sigma}_{j+1})$ and $({\sigma}_{j+1},{\sigma}_{j+2})$ tables.

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Sporring, J.; Darkner, S. Reconstructing Binary Signals from Local Histograms. *Entropy* **2022**, *24*, 433.
https://doi.org/10.3390/e24030433

**AMA Style**

Sporring J, Darkner S. Reconstructing Binary Signals from Local Histograms. *Entropy*. 2022; 24(3):433.
https://doi.org/10.3390/e24030433

**Chicago/Turabian Style**

Sporring, Jon, and Sune Darkner. 2022. "Reconstructing Binary Signals from Local Histograms" *Entropy* 24, no. 3: 433.
https://doi.org/10.3390/e24030433