Characterization of hv-Convex Sequences

Reconstructing a discrete object by means of X-rays along a finite set U of (discrete) directions represents one of the main task in discrete tomography. Indeed, it is an ill-posed inverse problem, since different structures exist having the same projections along all lines whose directions range in U. Characteristic of ambiguous reconstructions are special configurations, called switching components, whose understanding represents a main issue in discrete tomography, and an independent interesting geometric problem as well. The investigation of switching component usually bases on some kind of prior knowledge that is incorporated in the tomographic problem. In this paper, we focus on switching components under the constraint of convexity along the horizontal and the vertical directions imposed to the unknown object. Moving from their geometric characterization in windows and curls, we provide a numerical description, by encoding them as special sequences of integers. A detailed study of these sequences leads to the complete understanding of their combinatorial structure, and to a polynomial-time algorithm that explicitly reconstructs any of them from a pair of integers arbitrarily given.


Introduction
Reconstruction of finite discrete sets having prescribed projections is a challenging well-known inverse problem. In many cases, it shares its domain with Physics, Chemistry, Medical imaging and other areas where discrete models of real objects are employed. In discrete tomography, the object to be reconstructed is represented by a set of parallel slices, each modeling as a binary matrix the set of points of the object lying on the corresponding 2D plane. So, the basic problem is the reconstruction of a binary matrix from the collected projection data, that are obtained by means of X-rays in a set U of different directions.
Since the discrete sets consistent with a given set of projections are, in general, a huge number, and these can be In the literature, the connectedness constraints have been primarily investigated, and many meaningful results have been obtained, both concerning the reconstruction and the enumeration of possible solutions in such a restricted space (see [24,25] for an overview). Differently, one can confine the investigation to a given lattice grid A, so looking for uniqueness conditions inside A, or in suitable subregions of A (a non-exhaustive list of useful papers is [9,[14][15][16]22,23,26,28], also including the corresponding reference sections).
In case different discrete sets Y 1 and Y 2 are tomographically equivalent with respect to a set U of directions, namely when Y 1 , Y 2 can be reconstructed by means of the same Xrays with respect to U , then there exist specific patterns, called switching components which turn Y 1 into Y 2 . So, understanding the combinatorial and the geometric structure of the switching components is a main issue for a faithful reconstruction, largely investigated in discrete tomography, also in terms of ghosts or bad configurations (see, for instance [3,5,6,8,9,11,16,[18][19][20][21]23,27]).
The aim of the present paper falls in this area of research, and concerns finite discrete sets that are horizontally and vertically convex, and that share the same projections along those preferred directions, i.e., the horizontal and the vertical ones.
In particular, we are interested in the characterization of the switching components having a special geometrical condition, which defines a class of patterns called hv-convex switching components. It includes the classes of regular and of irregular switching components considered in [21], that, following [13], can be also defined in terms of hv-convex windows and hv-convex curls, respectively.
We show that these hv-convex switchings can be encoded by a sequence of integers. We provide a complete description of the combinatorial structures of such sequences, and an algorithm for their explicit constructions.
The paper extends and generalizes the results in [13]. It is structured as follows: in Sect. 2 we give the notations, and we provide the basic knowledge on switching components. We introduce windows and curls, then adding to both of them the hv-convex constraint, which leads to the basic Definition 5, where the notion of hv-sequence is stated. Section 3 contains one of the main results of our study, i.e. Theorem 17, which provides the characterization of the entries of the hvconvex sequences according to the number of points of the related hv-convex switching. In [13], only the easier case of hv-sequences related to windows had been focused, with a few sporadic examples concerning allowed or forbidden hvsequences of curls. This led to [13,Problem 1], which asked for the characterization of all hv-sequences. By Theorem 17, we have completely solved Problem 1, and, as a particular case, we get also the characterization of the hv-sequences having just one odd repeated entry (Corollary 18), which provides the curl counterpart of [13,Theorem 3], holding for windows. In Sect. 4, we deeper investigate the geometric and the combinatorial structure of the hv-convex switchings. Thanks to Theorem 25 and Algorithm 1, CompSeq, we characterize and compute the exact positions, inside the hvsequence, of the allowed entries, which frames in the proper context the sporadic cases considered in [13]. In Sect. 5, we provide a few concluding remarks, and outline some hints for possible further developments.

Notations and Preliminaries
We adopt the standard notation Z 2 to indicate the lattice of points of the Euclidean two-dimensional space having integer coordinates. For each point v ∈ Z 2 , we denote by L h (v) and L v (v) the horizontal and vertical discrete lines intersecting v, respectively. A set of points A ⊂ Z 2 , considered up to translations, is horizontally (resp. vertically) convex if, for A set that is both horizontally and vertically convex is shortly called hv-convex. A polyomino is a finite set of points in Z 2 whose elements are 4-connected.
For a finite set A, we define its horizontal (resp. vertical) projection to be the integer vector H (A) (resp. V (A)) counting the number of points of A that lie on each horizontal (resp. vertical) line intersecting A.
Given a point v = (i, j) ∈ Z 2 , the four following closed regions are defined (with the same notations as in [12,17]): Figure 1 shows simple examples of the introduced sets.

Lemma 1 Let A be an hv-convex polyomino, and consider
Proof By [7, Proposition 2.3], an hv-convex connected set is also Q-convex. The statement follows immediately by the hv-convex property of A.

Switching Components and the Uniqueness Problem
The following definition introduces the class of hv-switchings.
Definition 2 A pair S = (S 0 , S 1 ) of sets of points is a hvswitching if: i.e., S 0 and S 1 have the same horizontal and vertical projections.
Each set S 0 and S 1 is indicated as hv-switching component.
A discrete set A contains a hv-switching component if S 0 ⊆ A and S 1 ∩ A = ∅. In this case, we consider A = Y ∪S 0 , with Y being a (possibly empty) discrete set; we define the set A = Y ∪ S 1 as the dual of A, and we say that the switching S is associated to A and A .
A classical result in [27] states that if A 1 and A 2 are two discrete sets sharing the same horizontal and vertical projections, then A 2 is the dual of A 1 with respect to a hv-switching. So, for any point v ∈ S 0 (resp. v ∈ S 1 ), there exist points w 1 , w 2 ∈ S 1 (resp. w 1 , w 2 ∈ S 0 ) such that w 1 ∈ L h (v) and w 2 ∈ L v (v). Fig. 1 a A discrete set, and the corresponding horizontal and vertical projections, that is neither horizontally nor vertically convex. b An hv-convex set. c A convex set that is not Q-convex (the dashed cell does not belong to the set) If A 1 and A 2 are hv-convex sets, then, due to Lemma 1, for any v ∈ S there exists one and only one i ∈ {0, 1, 2, 3} such that Z i (v) ∩ S consists of points all belonging to the same component of S as v. The quadrant Z i (v) is said to be the free region of v, or the S-free region of v in case we wish to emphasize that the free region relates to the switching S. We denote by F(v) (or by F S (v)) the free region of v ∈ S. Also, F i (S) denotes the subset of S consisting of all points having free region We have the following result from [12] Lemma 3 Let S = (S 0 , S 1 ) be a hv-switching. Then, the following conditions are equivalent Let S = (S 0 , S 1 ) be a hv-switching.
The following definition introduces the subclass of hvswitching we wish to deal with.

Definition 4
A hv-switching S is said to be a hv-convex switching if the equivalent conditions of Lemma 3 hold.
In the literature, hv-convex switchings have been deeply studied when related to hv-convex polyominoes (for basic definitions and main results see [24,25]). In this context, it holds that if S = (S 0 , S 1 ) is a hv-switching associated to a pair of hv-convex polyominoes, then (1) holds, so S is an hvconvex switching. However, the converse is not necessarily true, namely two polyominoes P 1 and P 2 can exist such that one is the dual of the other with respect to an hv-convex switching S, and such that one or both of them are not hvconvex. An interesting case is Fig. 23 in [21], or Fig. 2.
In the sequel, we focus on the problem of characterizing the class of hv-convex switchings by integers' sequences, say hv-sequences, as defined below. Let us start by recalling the following classification of hv-convex switchings introduced in [12,13].
A closed polygonal curve K in R 2 is said to be a squared spiral if K consists of segments having, alternatively, horizontal and vertical direction. Their endpoints form the set of vertices of the polygonal. Assume to travel K according to a prescribed orientation. A vertex v of K is said to be a counterclockwise point if, crossing v, implies a counterclockwise change of direction. Differently, v is a clockwise point. Of course, by reversing the traveling orientation, clockwise and counterclockwise vertices mutually exchange.

Windows and curls.
A squared spiral W is said to be a window if it can be traveled by turning always clockwise, or always counterclockwise. Otherwise, the squared spiral is said to be a curl. Therefore, traveling a curl needs changes of turning direction. From now on, we will consider spirals whose vertices have integer coordinates.
We underline that the set of vertices of a window or a curl forms a hv-switching S = (S 0 , S 1 ) by considering the vertices alternatively belonging to S 0 and S 1 . Figure 3 shows an example of window and curl pointing out the elements belonging to different hv-switching components.
Let S be a squared spiral (window or curl). Suppose to select any vertex v, and start traveling S moving from v clockwise (or counterclockwise). So, visiting one vertex after the other, we can group them in ordered lists of consecutive clockwise and counterclockwise points.

Definition 5
Once an orientation of a squared spiral S has been chosen, let v be a vertex where the orientation changes. Starting from v, compute the lengths k 1 , k 2 , ..., k n of the lists of consecutive vertices having, alternatively, the same and the opposite orientation as v. The resulting sequence of integers π = (k 1 , k 2 , ..., k n ) is said to be the hv-sequence associated to S.
The sequence π is considered cyclically arranged, namely its first entry can be selected arbitrarily among k 1 , ..., k n , and then listing the others preserving the given order. If the sequence (k 1 , k 2 , ..., k n ) is periodic, then we adopt the nota- It is worth noticing that a (k 1 , ..., k n ) h hv-sequence encoding a squared spiral, in general does not guarantee its hv-convexity, since the conditions in Lemma 3 do not automatically hold. Figure 4-(a) shows a (12) hv-convex windows, while, in Fig. 4b it is represented a (7) 2 hv-convex curl.
Note that the hv-switchings (a) (resp. (b)) in Figs. 3 and 4 are windows and curls of the same type, and have the same number of points, but only in Fig. 4 the hv-convex property holds.
Our aim is to investigate the structure of the hv-sequences that are associated to hv-convex switchings, shortly the hvconvex sequences. In particular, we are concerned with the following problem.
Problem. Characterize, and explicitly reconstruct, the hvconvex sequence associated to any given window or curl.

Remark 6
The notions of hv-convex windows and hv-convex curls already appeared in the literature. For instance, these have been considered in [21] in terms of regular and of irregular switching components. Also, the staircases studied in [1], and the staircase-like structures in [2], are special cases of windows.
A straightforward property of hv-convex switchings is: Proposition 7 Each horizontal and vertical line intersecting an hv-convex switching S = (S 0 , S 1 ) contains precisely two points of S, one in S 0 and one in S 1 .
The easiest case concerns the hv-convex sequences associated to windows. Let us recall the following result from [13]: Theorem 8 Let W be a window of size n ≥ 1 and let {w 1 , w 2 , ..., w 4n } be the set of its vertices as encountered when traveling W from any fixed vertex, and with a given orientation. Then, W is an hv-convex switching if and only if a point x ∈ R 2 exists such that w i ∈ Z 0 (x) ∪ Z 2 (x) for all the odd indices, and w i ∈ Z 1 (x) ∪ Z 3 (x) for all the even indices.
In [13, Theorem 3], a simple characterization had been given for what concerns the hv-convex sequences associated to hv-convex windows. For the convenience of the reader, we repeat below the proof.

Theorem 9 For each n > 0, an hv-convex switching S has hv-convex sequence π = (4n) if and only if S is an hv-convex window.
Proof Suppose that S is a window. Then, there exists a point x as in Theorem 8. Note that all quadrants Z i (x), i ∈ {0, 1, 2, 3} contain the same number of points of S. Since S has 4n vertices, and can be traveled by turning always in the same direction, then π = (4n). Conversely, assume that an hv-convex sequence is π = (4n). Since π consists of a single entry, then no change of direction occurs when traveling S, so S is a window, and, from the knowledge that π is an hv-convex sequence, we get that S is an hv-convex window.
Breaking the constraint of the existence of the point x ∈ R 2 provides an easy way to define windows of whatever Differently, the characterization of the hv-sequences associated to hv-convex switchings represented by curls, shortly hv-convex curls, represents a quite challenging task. We address this problem in the following section.

Structure of hv-convex Sequences Associated to Curls
We move from the following result in [12,13]: Theorem 10 Let C be an hv-convex curl and let v and w be two of its vertices with the same orientation. If precisely 2n > 0 consecutive vertices between v and w exist having their opposite orientation, then C is not an hv-convex curl.
Theorem 10 implies that the elements of each hv-convex sequence related to an hv-convex curl are odd numbers. For instance, Fig. 4, (a), provides an example where the only entry 7 appears, repeated twice. Differently, in Fig. 5, examples are shown of hv-convex sequences with two different entries.

Relating hv-convex Curls to Dual Polyominoes
As a first step, let us show how an hv-convex curl can be associated to a discrete set in order to produce two dual hv-convex polyominoes. It is well known that an hv-convex polyomino has the general form as those depicted in Fig. 5. The points of an hv-convex polyomino that touch the sides of its minimal bounding rectangle are called N(orth), S(outh), E(ast) and W(est) feet, according to their positions.
We denote by XY -side the boundary of an hv-convex polyomino running from the X foot to the Y foot, with X ∈ {N , S}, and Y ∈ {E, W }. Also, P(S) represents an arbitrary hv-convex polyomino associated with an hv-convex switching S.
We observe that the two components of an hv-convex switching that are associated to two dual hv-convex polyominoes, must lie on the border of the two polyominoes, in order to preserve horizontal and vertical convexity for both of them, as shown in Fig. 5.

Lemma 11
Let π be an hv-convex sequence, S be the corresponding hv-convex switching, and P(S) be an arbitrary hv-convex polyomino associated to S. Then, π depends only on the number of points of S lying on two consecutive sides of P(S).
Proof The hv-convex sequence π encodes the alternating lists of clockwise and counterclockwise oriented vertices of S. Since S is a squared spiral, then its vertices are the endpoints of horizontal and vertical sides, and, being S a switching component of P(S), then its vertices all belong to the four sides of P(S). Since the vertices of S correspond pairwise along horizontal and vertical lines, all of them are completely determined just by the subset of vertices belonging to two consecutive sides of P(S).

Corollary 12
Let π be an hv-convex sequence associated to an hv-convex switching S. Let a an b be the number of points of S lying, respectively, on the N E-side, and on the S E-side of P(S). If π = (k 1 , . . . , k n ) 2 , then k 1 + . . . + k n = a + b.
Proof Since π = (k 1 , . . . , k n ) 2 , then S has 2(k 1 + . . . + k n ) vertices. By Lemma 11, the number of vertices of S is twice   Fig. 5, (a), the hv-convex sequence π = (3, 1, 1) 2 is considered. According to Corollary 12, we must have 3 + 1 + 1 = 5 points on two consecutive sides. Up to rotations, this allows four points lying on the N E-side, and one point on the S E-side. By symmetry, we also have four points on the N W -side and one point on the SW -side. In Fig. 5, (b), the sequence (5, 3) 2 allows five points to lie both on the N E-side and on the SW -side, and three points to lie both on the N W -side and on the S E-side.

Remark 13
A curl C can be uniquely associated to a couple of integers a and b that count the number of points that lie, respectively, on the N E-side, and on the S E-side of P(C). Therefore, we can also adopt for C the notation Curl(a, b).
We aim in finding an explicit way for the reconstruction of the whole hv-convex sequence related to Curl(a, b) from the only knowledge of the integers a and b. To this, we introduce in the following section two important operators, acting on the labeled vertices of Curl(a, b).

The Horizontal and the Vertical Shift Operators
From now on, let us label the n points of an hv-convex curl C by 1, 2, . . . , n, starting from the lowermost point in the N Eside of P(C), and moving counterclockwise, as depicted in Fig. 5b. Furthermore, let a (resp. b) be the number of points of C lying on the N E-side and SW -side (resp. N W -side and S E-side) of P(C), and assume w.l.g. (by reflection along the horizontal axis) a ≥ b. We identify each point x ∈ C with its label (mod (2a + 2b)), and we define its horizontal and vertical shifted version H (x) and V (x), respectively, as follows: We recall that in case a = b, the corresponding switching component is a window whose sequence is of the form (4h). So the label of z turns out to be a Cases (iii) and (iv), i.e., when x lies either on the SW -side or on the S E-side of P(C), can be treated analogously. The reader can check these remaining cases on Fig.5, (b).

Lemma 15
Let π be an hv-convex sequence corresponding to an hv-convex curl C. For every odd α = 2h + 1 ∈ π , there exists a consecutive sequence x 1 , . . . , x α of points of C traveled with the same orientation such that the label of x α is 2hb + x 1 (mod (2a + 2b)) if x 1 and x 2 lie in the same row, while if they lie in the same column, the label is 2ha + x 1 (mod (2a + 2b)).
Proof Let us first assume that the path from x 1 to x 2 is horizontal. The points x 1 , . . . , x α have labels

By Lemma 14, it holds
So, the label of the point x α turns out to be On the other hand, if the path from x 1 to x 2 is vertical, the labels of the points x 1 , . . . , x α are
The next theorem provides a complete characterization of the combinatorial structure of Curl(a, b) for any possible choice of a and b, also showing that the corresponding hv-convex sequences always consist of one or two different repeated entries.

Remark 16
For the sake of brevity, in what follows sentences of the form "the point x belongs to the X Y -side of P(C)" are often simply replaced by x ∈ XY . Theorem 17 Let a, b ∈ N, with b < a, and let π be the hv-convex sequence associated to C = Curl(a, b). Then, π consists of N α entries α = 2h+1, and N γ entries γ = 2h+3, where Proof Let x ∈ [1, b], and note that , and has the same orientation of V (x), say clockwise without loss of generality. Therefore, each such x is the endpoint of a path in Curl(a, b). Note that Consequently, x is the starting point of a clockwise oriented path of minimal length α = 2h + 1 if and only if the following conditions hold Suppose that h = 2k for some k ≥ 0. We have Condition (i) provides so that x ranges in the interval ((2k + 1) Matching with (6), and with x ∈ [1, a − b], we obtain This implies and (5) follows. Therefore, if h = 2k, and , any clockwise oriented path starting at x, must have length 2h + 1 = α, and consequently h > h, due to the minimal assumption on α. Let us consider h = h + 1. Then, h is odd, so H V h (x) ∈ SW . Since h is even, it is −ha = hb (mod (2a + 2b)), so, also exploiting (7), we get This means that any x ∈ [1, (h+1)b−ha] is the starting point of a path of length γ = 2h + 1 = 2h + 3. Therefore, there exist N γ 1 = (h + 1)b − ha entries of π equal to γ = 2h + 3. When x ∈ [1, a − b], we get N α 1 + N γ 1 entries of π , corresponding to disjoint paths of length α and γ , respectively. These paths include a number of points of Curl(a, b) given by By symmetry, the same arguments can be applied to paths having starting points at x ∈ [a + b + 1, 2a], which provides N α 2 = N α 1 paths of length α, for x ∈ (a + b + (h + 1)b − ha, 2a], and N γ 2 = N γ 1 paths of length γ , for x ∈ [a + b + 1, a + b + (h + 1)b − ha]. These paths include a + b additional points of Curl(a, b). Consequently, we have entries of π equal to γ = 2h +3. These entries correspond to paths of Curl(a, b) which include 2a + 2b different points. Since Curl(a, b) contains exactly 2a + 2b points, then the sequence π cannot have any further entry, and the statement follows.
Suppose now that x ∈ [1, a − b], and h = 2k − 1 for some k ≥ 1. Then, we can write Condition (ii) provides so that x ranges in the interval (hb−ha +b, hb−ha +a +b]. Matching with (8), and with x ∈ [1, a − b], we get x ∈ (hb − ha + b, a − b], under conditions (5). This provides again N α 1 = (h + 1)a − (h + 2)b as in the case when h is even. Therefore Differently, if h = 2k − 1, and x ∈ [1, hb − ha + b], any clockwise oriented path starting at x, must have length 2h + 1 = α, and consequently h > h, due to the minimal assumption on α. Let us consider h = h + 1. Then, h is odd, so (H V ) h (x) ∈ N E. Being h = h + 1 even, we can write Since x ∈ [1, hb − ha + b], then by (5), we get This means that any x ∈ [1, (h + 1)b − ha], is the starting point of a path of length γ = 2h + 1 = 2h + 3. Therefore, there exist Consequently, for any x ∈ [1, a − b], we have the same results as in the case h even. By symmetry, the same holds also for x ∈ [a + b + 1, 2a], and the statement follows.
The following corollary characterizes the hv-sequences having just one odd repeated entry, so it represents a kind of curl counterpart of the case of windows according to Theorem 9.

Corollary 18 For any a, b ∈ N, a > b, the entries of the hvconvex sequence π associated to Curl(a, b) are all equal if and only if b a−b is an integer. In addition, the 2(a − b) entries in this case are all equal to a+b a−b .
Proof If b a−b is an integer, then, by (5), h = b a−b , so (4) provides N γ = 0, and, by (3), ), which proves the statement.

Remark 21
The case a > 2b is the only one that allows entries equal to 1 to appear in the hv-convex sequence.

The Structure of hv-convex Switchings
Theorem 17 shows that any hv-convex sequence consists of one or two repeated entries. Corollary 18 characterizes the case when the hv-convex sequence consists of just one repeated entry. Differently, the problem of understanding how the entries α and γ mutually alternate in π becomes relevant. To this, we need to know the labels of the endpoints of the paths having lengths α and γ .

Remark 23
In what follows, all the involved intervals consist of just integer labels, even if the simplified "continuous" notation (a, b], (instead of (a, b] ∩ N) is adopted.
To address the above problem, we first apply CompSe-qEntries as pointed out in Remark 19, in order to prove the following.

Lemma 24
According to the parity of h, it holds -h ≥ 0 even: Theorem 25 Let us consider two integers a and b such that a > b. According to what defined in Theorem 17, let C and P(C) be the hv-convex curl and the hv-convex polyomino associated to a and b, and compute the values of h, α, γ , N α and N γ . We define the following sets of (integer) labels: Fig. 6 A hv-convex switching C with a = 28 and b = 5 It holds that the elements of I α (resp. I γ ) are exactly (the labels of) the endpoints of the same-oriented paths of length α (resp. γ ) of the hv-convex curl C.
Proof Let us assume w.l.g. that the point with label x lies in the N E-side of P(C) and it is the first point of a path traveled clockwise. From this assumption, it immediately follows that . So, such a path has a vertical first side. Lemma 15 assures that the last point of the path is (H V ) h (x) = 2ha + x (mod (2a + 2b)) if and only if its length is α = 2h + 1. The following two cases arise: between V (a) and 2a + b. It follows the inequality and by Lemma 24 As a consequence, the previous condition x ∈ 1, between a and V (2a + b). It follows the inequality and furthermore, 1+b ≤ 1−2ha−x (mod (2a+2b)) ≤ a and by Lemma 24 Since it also holds h ≤ 1 and 2hb − b ≥ b, then the first inequality is always verified. Again, by the second inequality, the condition x ∈ 1, Summing up, if a path of length α has starting point x in the N E-side of P(C), then it holds x ∈ N γ 2 , Let us now focus on the final point (H V ) h (x) of the path: it lies on the N E-side of P(C) when h is even, and it lies on the SW -side of P(C), otherwise. Again, let us analyze the two cases more precisely: h even: by Lemma 24 it holds 2ha (mod (2a h odd: a similar computation as in the previous case, from In case the path is traveled counterclockwise and/or the starting point of the path lies on the SW -side of P(C), then the previous results continue holding, up to a rearrangement of the starting and the ending points. These computations show that the point x can also belong to the interval a + b + , while the ending according to the parity of h. So, the extremal points of the paths of length α correspond to the set I α .
Concerning the set I γ , we suppose that the final point of a path starting in x is of the form 2a + 2b)), i.e., its length is γ = 2h + 3.
The same reasoning as for the case of the α length paths can be used after updating h with h + 1 and up to exchanging the N W -side and the S E-side of P(C). More precisely: Since 1 − N α 2 < 0 the second inequality is always verified, so the first inequality allows the condition x ∈ 1, between V (a) and 2a + b. It follows the inequality and, by Lemma 24, Since N γ 2 − a + b = − N α 2 < 0, then the second inequality is always verified. Again, by the first inequality, the condition x ∈ 1, Summing up, if a γ length path starts from a point x in the N E-side of P(C), then x ∈ 1, N γ 2 . The last point of the path (H V ) h+1 (x) lies on the SW -side of P(C) if h is even, and on the N E-side of P(C) otherwise: h even: by Lemma 24 it holds 2ha (mod (2a + 2b)) = − h odd: a similar computation leads to In case the path is traveled counterclockwise and/or the starting point of the path lies on the SW -side of P(C), then the previous results continue holding, up to a rearrangement of the starting and the ending points. These computations show that the point x can also belong to the interval a + b + 1, a + b + Denote by π j the subsequence of π consisting of its first j-entries.
The following theorem provides the answer to how the entries α and γ mutually alternate in the hv-convex sequence S. Theorem 26 Let a, b ∈ N, with a > b, and let d = gcd(a, b). Then, the hv-convex sequence π associated to Consequently, we get Let j ∈ 1, , and let x j be the starting point of the j −th walked path. Then, the label of the starting point of the Assume d = 1, and compute f λ (x j ) in the different allowed cases. We have (i) If a − b is even, then, being d = 1, both a and b are odd integers, so a > b implies a > 1, and consequently 2b)), and we can write (ii) If a − b is odd, we consider two subcases.
(a) a is even and b is odd. We have Therefore, we get (b) a is odd and b is even. We have 2a + 2b)).
Consequently, we can write In all the cases, by Theorem 25 it follows that x j ∈ I α if and only if y j ∈ I α , and x j ∈ I γ if and only if y j ∈ I γ . Consequently, the entries of π repeat after the first Then, with the same arguments, we obtain that the sequence associated to Curl(a , b ) is (π a −b ) 2 . Therefore, the sequence π associated to Curl(a, b) is obtained by repeating (π a −b ) 2 for d times, namely π = (π a −b ) 2d , and the statement follows.
Theorems 25 and 26 lead to algorithm CompSeq, which returns the hv-convex sequence π consisting of entries α and γ , and associated to Curl(a, b), for any pair of integers a, b, a > b. The algorithm also exploits the procedure CompSe-qEntries defined in Remark 19.

Remark 28
Let C 1 and C 2 be two hv-convex curls having the same hv-convex sequence π . Then, C 1 and C 2 can be merged into one single hv-convex curl whose hv-convex sequence is (π ) 2 .
The proof is straightforward. Figure 8 shows an example of the merging process: the curls C 1 and C 2 are placed one next to the other as shown in Fig. 8, (a), and two of their neighbors points belonging to the same switching component (in Fig. 8 the points inside the red circle) exchange one of their coordinates.
We underline that the merging process can be iterated when more than two hv-convex curls are involved. Again the process ends up in one single hv-convex curl.

Concluding Remarks
In this paper, we have considered hv-convex switching components, namely the switching components under the prior knowledge that the object to be reconstructed is convex along the horizontal and the vertical directions. These are separated in two different geometric classes, windows and curls respectively (see [12,13]), and can be encoded as special sequences of integer numbers, called hv-sequences. We have provided a detailed investigation of hv-sequences, so obtaining a complete combinatorial description. In case of windows, the related hv-sequences are quite simple, since reduce to a single multiple of 4, that can be easily determined by the geometric structure of the switching component. Differently, for curls, hv-sequences consist of alternating strings of odd entries α, γ . The numerical values of α and γ , as well as the lengths of each string occurring in a given hv-sequence, can be exactly computed by exploiting two integer numbers a, b, that are related to the geometric structure of the curl (denoted by Curl(a, b) for such a reason). A polynomialtime algorithm in a, b has been provided, which explicitly reconstructs the hv-sequence related to Curl(a, b), and several examples have been shown and discussed in detail.
The knowledge of the combinatorial structure of hvconvex sequences, and consequently the geometric properties of the hv-convex switching components, is of main relevance for the faithful reconstruction of hv-convex polyominoes.
Furthermore, it is well known that small modifications of the projections may lead to dramatic changes in the reconstructed object. The reconstruction process is called stable if a small amount of noise can only lead to small differences in the reconstruction So, it is of primary relevance to understand both the structure and the size of the switching components of a reconstructed object to estimate how far it is from the original one, when noisy projections are provided (the reconstruction process is called stable if a small amount of noise produces small differences in the reconstruction).
We feel that the obtained results provide additional knowledge on the geometric and combinatorial properties of the switching components, which could be exploited and incorporated in the tomographic problem in view of a reduction of the number of allowed solutions. Also, this could reveal of interest when used in combination with the system of clauses involved in the P-time reconstruction process defined in [4], in order to possibly reduce them to a 2-SAT formula.
A final possible challenging problem consists in relating the geometrical and the combinatorial structure of the hvconvex switching components and sequences to the degree of convexity of the associated hv-convex polyominoes, according to the definition in [10]. In particular, it is interesting to investigate the possible co-existence of hv-convex windows and curls in a same hv-convex polyomino, aiming at deriving some limitations on the number and the type of allowed switching components (see also [21]), in view of a solution of the computational complexity problem of the reconstruction of digital convex polyomino from two projections.
Funding Open access funding provided by Politecnico di Milano within the CRUI-CARE Agreement.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecomm ons.org/licenses/by/4.0/.