Binary Image Reconstruction Based on Prescribed Numerical

Acta Mathematicae Applicatae Sinica, English Series
Vol. 31, No. 2 (2015) 519–528
DOI: 10.1007/s10255-015-0482-4
http://www.ApplMath.com.cn & www.SpringerLink.com
Acta Mathemacae Applicatae Sinica,
English Series
The Editorial Office of AMAS &
Springer-Verlag Berlin Heidelberg 2015
Binary Image Reconstruction Based on Prescribed
Numerical Information
K.G. Subramanian1 , Pradeep Isawasan1 , Rahmat Budiarto2 , Ibrahim Venkat1
1 School of Computer Sciences, Universiti Sains Malaysia, 11800 USM Penang, Malaysia
(Email: [email protected], [email protected], [email protected])
2 Networked
Computing Center, Surya University, Serpong, Tanggerang, 15810, Indonesia
(Email: [email protected])
Abstract The problem of reconstruction of a binary image in the field of discrete tomography is a classic
instance of seeking solution applying mathematical techniques. Here two such binary image reconstruction
problems are considered given some numerical information on the image. Algorithms are developed for solving
these problems and correctness of the algorithms are discussed.
Keywords
discrete tomography and binary image and reconstruction and subwords and Parikh matrix
2000 MR Subject Classification
1
94A08
Introduction
Tomography is concerned with an imaging procedure that leads to reconstruction of the internal
structure of an object, without causing any damage to the object itself[1] . Image reconstruction is used in many application areas, especially in medical imaging, crystallography, image
processing and so on[14] . A large number of projections might be needed in order to carry out
reconstruction sufficiently accurately, although it may be difficult to acquire a large number of
projections in certain applications. Discrete Tomography (DT) is a promising and developing
field of research investigating the problem of image reconstruction, especially of binary images,
from a small number of projections. A binary image is a rectangular array of pixels, each of
which is either black (value 0) or white (value 1). Although reconstruction in DT is based on a
small number of projections, the reconstruction problem is still undetermined. For an excellent
source on this and various other aspects of Discrete Tomography, we refer to [11,12]. This field
is closely related to different applications of mathematics or more specifically, discrete mathematics (see for example, [2,25]). Ryser[20] and Gale[10] have independently given a necessary
and sufficient condition for a given pair of vectors to be the projections of a binary matrix along
horizontal and vertical directions, with the projections being the row and column sums of the
binary matrix. Subsequently, reconstruction of binary images considered as matrices of 0′ s and
1′ s with some constraints or some prescribed information, has been one of the problems that
has received great attention from researchers in this field (see [3–9,12,14,16].
Motivated by these investigations, here we consider two problems of reconstruction of a
Manuscript received July 9, 2012. Revised October 17, 2013.
The first author K.G. Subramanian and the fourth author Ibrahim Venkat gratefully acknowledge support
for this research respectively from a FRGS grant No. 203/PKOMP/6711267 and an ERGS Grant No.
203/PKOMP/6730075 of the Ministry of Higher Education (MoHE), Malaysia. The second author Pradeep
Isawasan would like to thank MoHE for the award of MyPhD under which this research was jointly carried out
by him.
520
K.G. SUBRAMANIAN, P. ISAWASAN, R. BUDIARTO, I. VENKAT
binary image, given some prescribed numerical information of the image. The first problem
is on constructing a binary image given the row projection in one direction, with the row
projection consisting of the number of 1′ s and the number of subword (also called scattered
subword) 01 in the rows of the binary image. We note that in a projection in general, the
number of 1′ s in the image in the direction of projection is counted but here we have included
in the projection some additional constraints, namely, the number of subwords 01 in the rows
of the binary image to be reconstructed. The second problem is on constructing a binary image
M given its row projection as in the first Problem, so that M has as its prefix or suffix, another
binary image M1 whose row projection is also given. Correctness of the algorithms are also
shown.
2
Preliminaries
Let Σ = {0, 1} be a binary alphabet. A word w over Σ is a finite sequence of symbols of Σ. The
set of all words over Σ is denoted by Σ∗ which includes the empty word λ, which is an empty
sequence of symbols. Given a word w = a1 a2 · · · an , ai ∈ Σ, a subword s of w is a subsequence
of w of the form s = b1 b2 . . . bk , k ≤ n where each bi equals some aj (1 ≤ j ≤ n) in w such that
w = x1 b1 x2 b2 · · · xk bk xk+1 , xi ∈ Σ∗ , i = 1, 2, · · · k + 1.
Fig. 1. (a) Chessboard patterns; (b) Binary matrix representation of the patterns
Extending the well-known concept of Parikh vector [19,21] of a word w which counts the
number of each of the symbols of an ordered alphabet in w, the notion of Parikh matrix of
a word was introduced in [18]. For a binary word over {0, 1}, the Parikh vector of the word
counts the number of 0′ s and 1′ s. For example, the Parikh vector of the binary word 1011001
is (3, 4). The Parikh matrix of a word w over an ordered alphabet gives, by counting certain
subwords in w, more information than a Parikh vector does. The notion of Parikh matrix is
known to play a significant role in the study of subwords of a given word (See for example,
[17,22,23]). In particular, for a binary word w over {0, 1} with the ordering 0 < 1, the Parikh
Binary Image Reconstruction Based on Prescribed Numerical Information
521
matrix is of size 3 × 3 and is given by


m13
m23  ,
1
1 m11
P = 0
1
0
0
where m11 = the number of 0′ s, m23 = the number of 1′ s and m13 = the number of subword
01′ s, in w. A binary image M of size m × n is a binary matrix or a (0, 1)-matrix with m rows
and n columns. Each row (as well as column) of M is a word in Σ∗ . where Σ = {0, 1}. For
example, interpreting 0 as a ‘white square’ and 1 as a ‘black square’, the binary images of the
chess-board patterns in Fig. 1(a) are binary matrices as shown in Fig. 1(b).
3
Reconstruction of Binary Images
In this section we consider two problems of reconstruction of a binary image with apriori
numerical information on its rows.
3.1
Algorithm for Problem 1
In the Problem 1, information on the number of 1′ s and the number of subword 01 in each
row of an unknown binary image is given and we give an algorithm, called Algorithm A, to
construct a binary image satisfying the given numerical information. Also the Algorithm A can
deal with binary images of different sizes but might reconstruct only one among many binary
images having the same numerical information on the number of 1′ s and the number of subword
01.
We now introduce a vector P (w), called row projection, that captures the information in
Problem 1.
Definition 1. Given a binary image M of size m × n that is a (0, 1)-matrix with m rows and
n columns, we associate with each row, a vector as follows: If wi is the binary word of 0’s and
1’s in the ith row of M , then P (wi ) = (qi , ri ), i = 1, 2, · · · m where qi = the number of 1′ s in
wi and ri = the number of subword 01 in wi . We refer to P (wi ) as a row projection.
Remark 1. i) Note that if pi is the number of
pi = n − qi . In fact, the matrix

1 pi

 0 1
0 0
0′ s in the word wi in the ith row of M , then

ri

qi 
1
is the Parikh Matrix of wi with the ordering 0 < 1.
ii) A binary word w of length n, with the number of 1’s = q and the number of 0′ s = (n − q),
and for which the Parikh matrix is P with the ordering 0 < 1, need not be unique in the
sense that there could be several binary words with the number of 1’s = q and the number of
0′ s = (n − q) and having the same Parikh matrix P . For example the words 011001011 and
101000111 with five 1′ s and four 0′ s have the same Parikh matrix


1 4 13


 0 1 5 
0 0 1
522
K.G. SUBRAMANIAN, P. ISAWASAN, R. BUDIARTO, I. VENKAT
. We now state the Problem 1.
Problem 1. Given m vectors vi = (qi , ri ), i = 1, 2, · · · m, ri ≤ (n − qi )qi where n, qi , ri are
non-negative integers and 0 ≤ qi ≤ n, to construct a binary image of size m × n, whose row
projections are vi , i = 1, 2, · · · m.
Next we state an Algorithm A to construct a binary image given row projections as in
Problem 1.
Algorithm A.
Input : The positive integers m and n; Vectors vi = (qi , ri ), i = 1, · · · m, where qi , ri are
non-negative integers, ri ≤ (n − qi )qi and 0 ≤ qi ≤ n.
Output : A binary image of size m × n with row projections vi (i = 1, 2, · · · , m).
Step 1 : Form a binary image M of size m × n with the ith row having qi consecutive 1′ s
from the left end of the row and (n − qi ), 0′ s after the 1′ s for i = 1, · · · , m.
Step 2 : For i = 1, · · · , m do:
Set ki = 0. Shift the last 1 in the consecutive 1′ s in the row i over the 0′ s, one by one,
incrementing ki by 1 for each shift till ki = ri or there is no zero left to do the shifting. If
ki < ri , shift the next last 1 in the consecutive 1′ s in row i, over the 0′ s, one by one, again
incrementing ki by 1 for every shifting. Repeat the process until ki = ri .
If in a row i, ki = ri , then stop the shifting.
Step 3 : The resulting binary image M is the required binary image.
We state in the following lemma, a property[18] of the Parikh matrix P of a binary word w,
which is useful in showing the correctness of the Algorithm A.
Lemma 1.
If the Parikh matrix of a binary word w over {0, 1} with the ordering 0 < 1, is

1
P = 0
0
m11
1
0

m13
m23  ,
1
then we have
m13 ≤ m11 m23 .
Correctness and Complexity of the Algorithm A: A necessary condition for a binary image M
having the row projections as in Problem 1, to exist, is that ri ≤ (n − qi )qi for all i = 1, 2, . . . m.
This condition is a consequence of the Lemma 1. Also Step 1 of the algorithm ensures the
presence of the requisite number of 1′ s in each row. Subsequent steps do not increase or
decrease the number of 1′ s. Shifting a 1 over a 0 in a row contributes 1 to the count of the
number of subword 01 and the checking condition finally yields the requisite number of subword
01. This explains the correctness of the algorithm. The complexity of the algorithm is O(mn),
where the size of the reconstructed binary matrix is m × n, since in each row at the most only
(n − 1) 0′ s need to be filled and this activity needs to be done in each of the m rows.
We illustrate the working of the Algorithm A with an example.
Example 1.
Input : m = 4, n = 5; v1 = (3, 6), v2 = (3, 4), v3 = (2, 4), v4 = (2, 3). It can be verified
that the necessary condition is satisfied for the required binary image to exist.
523
Binary Image Reconstruction Based on Prescribed Numerical Information
Step 1 : The binary matrix



M =

1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0



.

Step 2 : k1 = k2 = k3 = k4 = 0. Shifting the 1’s in the row of M as in the Algorithm A,
yields the following sequence of steps:





1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0






 −→ 


1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
1





k1 = 2 < r1 = 6, k2= 2 < r2 = 4, k3 = 3 < r3 = 4, k4 = 3 = r4 (No more shifting of 1’s in
row 4) →
1
1
0
1
2 and 3) →
0011
0011

1 0 0 1 , k1 = 4 < r1 , k2 = 4 = r2 , k3 = 4
0001


00111
 1 0 0 1 1 , k1 = 6 = r1 (No more shifting
01001
10001
Step 3 : The output binary matrix is

0
1
0
1
0
0
1
0
1
0
0
0
1
1
0
0

1
1

1 .
1
= r3 (No more shifting of 1’s in rows
of 1’s in row 1).
The output matrix has four rows and
five columns. The row projections of this matrix are (3, 6), (3, 4), (2, 4), (2, 3).
Fig.2 (a) Binary output image of Example 1,
(b) A binary image with the same row projections as the image in Fig.2(a)
Remark 2.
i) Note
 that in
 Example 1, the Algorithm A constructs and can construct only
0 0111
1 0011
 which is one among a finite number of matrices having the same
the output matrix 
0 1001
1 0001
projections m = 4, n = 5; v1 = (3, 6), v2 = (3, 4), v3 = (2, 4), v4 = (2, 3) given as input.
Fig.2(a) shows the binary output image of the output matrix of Example 1 and Fig.2(b) shows
another binary image which also has the same row projections as that of the output image
of Example 1. This is the problem of uniqueness that is generally present in binary image
reconstruction. Depending on the constraints prescribed on the image to be reconstructed, the
task of uniqueness is dealt with and we address this question in the following subsection by
524
K.G. SUBRAMANIAN, P. ISAWASAN, R. BUDIARTO, I. VENKAT
exhibiting a specific class of binary images for which the Algorithm A will construct the image
uniquely.
ii) The reconstruction Problem 1 is in fact considered in Algorithm 1 in [?] and this Algorithm 1 reconstructs a binary image based on apriori information in terms of Parikh matrices
of the words in the rows of the image. But the manner in which our Algorithm A constructs
the rows of the binary image, is different yet simpler than that considered in [?]. In fact only
matrices with the same number of rows and columns are reconstructed in [15].
3.2
Uniqueness of Reconstruction
We now examine a specific type of binary image in which the binary word in each row of the
binary image, is an element of the set
U = 0∗ 1∗ + 1∗ 0∗ + 0∗ 10∗ + 1∗ 01∗ + 0∗ 101∗ + 1∗ 010∗ .
Here 0∗ stands for the set of all words over {0} and + denotes set union. The correspondence
between a word in this set and its Parikh matrix is known[17,22] to be one-to-one. In other
words, if P is the Parikh matrix of any word w in U, then no other binary word over {0, 1}
with 0 < 1, has the same binary matrix P. This implies that the binary image constructed by
the Algorithm A will be unique, if the binary word in each row of the binary image, belongs
to the set U which means that the row projections vi = (qi , ri ) given as input to the algorithm
should satisfy the feature that ri = the number of subword 01 for some word in U. The following
example illustrates this feature.
Example 2.
Input : m = 4, n = 5; v1 = (2, 1), v2 = (2, 5), v3 = (2, 6), v4 = (1, 3).
Step 1 : The binary matrix
1
1
M =
1
1

1
1
1
0
0
0
0
0
0
0
0
0

0
0
.
0
0
Step 2 : k1 = k2 = k3 = k4 = 0. Shifting the 1’s in the row of M as in the algorithm




1 0 1 0 0
1 1 0 0 0
 1 0 0 0 1 
 1 1 0 0 0 




A, yields the following sequence of steps: 
 , k1 =
→
 1 0 0 0 1 
 1 1 0 0 0 
0 0 0 1 0
1 0 0 0 0
1 = r1 , k2 = 3 < r2 , k3 = 3 < r3 , k4 = 3 = r4 (No more shifting of 1’s in rows 1 and 4)


1 0 1 0 0
 0 0 1 0 1 


→
 , k2 = 5 = r2 , k3 = 6 = r3 (No more shifting of 1’s in rows 2 and 3).
 0 0 0 1 1 
0
0 0
1 0
Step 3 : The output binary matrix is

1
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1

0
1

1 .
0
The output matrix has four rows and five columns. The row projections of this matrix are
(2, 1), (2, 5), (2, 6), (1, 3). All the binary words
10100, 00101, 00011, 00010
Binary Image Reconstruction Based on Prescribed Numerical Information
525
in the rows belong to the set U .
Fig.3. Binary Output Image of Example 2
3.3
Algorithm for Problem 2
We next consider reconstruction Problem 2. We first recall some notions needed. Given two
binary images M1 of size m × n and M2 of size m × l , the column catenation of M1 and M2 is
the binary image M = M1 M2 of size m × (n + l ). M1 is said to be a prefix of M and M2 , a
suffix of M.
Problem 2. The row projections vi = (qi , ri ), i = 1, 2, · · · m, ri ≤ (n − qi )qi where n, qi , ri
are non-negative integers and 0 ≤ qi ≤ n of a binary image M1 are given. A positive number s
is given. The problem is to construct a binary image M of size m × (1 + s)n whose projections
are ((1 + s)qi , (1 + s)ri + spi qi ), i = 1, · · · , m where pi = n − qi and M1 is a prefix of M or a
suffix of M.
Next we state the Algorithm B in order to construct a binary image as required in Problem
2.
Algorithm B.
Input : s, m and n are the positive integers. m vectors vi = (qi , ri ), where qi , ri are
non-negative integers, ri ≤ (n − qi )qi and 0 ≤ qi ≤ n.
Output : A binary image M of size m × n(1 + s) with row projections ((1 + s)qi , (1 + s)ri +
spi qi ), i = 1, · · · , m such that M has a prefix or a suffix, the binary image with row projections
vi = (qi , ri ), i = 1, 2, · · · m.
Step 1 : Apply Algorithm A to construct a binary image M1 with row projections vi =
(qi , ri ), i = 1, 2, · · · m and another binary image M2 with row projections (sqi , sri ), i =
1, 2, · · · m
Step 2 : The binary image Mp = M1 M2 and Ms = M2 M1 are the required binary images,
both having the size m × n(1 + s) and row projections ((1 + s)qi , (1 + s)ri + spi qi ), i = 1, · · · , m.
The binary image Mp has M1 as a prefix and the binary image Ms has M1 as a suffix.
We now state another property[23] of Parikh matrices of binary words that ensures that
Algorithm B works correctly.
526
Lemma 2.
K.G. SUBRAMANIAN, P. ISAWASAN, R. BUDIARTO, I. VENKAT
If s > 0, and w1 and w2 are two words respectively having Parikh matrices


r

q 
1
1 p

P1 =  0 1
0 0
and


sp sr

1 sq  ,
0 1
1

P2 =  0
0
then both w1 w2 and w2 w1 have the same Parikh matrix


1 (1 + s)p (1 + s)r + spq


P = 0
1
(1 + s)q
.
0
0
1
Correctness of the Algorithm B: The binary word in any row of Mp is of the form xy with
x being a word in a corresponding row of M1 and y being a word in a corresponding row of
M2 . Also the row projection of x is of the form (qi , ri ) while the row projection of y is then
of the form (sqi , sri ), for some i, 1 ≤ i ≤ m. In view of Lemma 2, the row projection of xy is
((1 + s)qi , (1 + s)ri + spi qi ) where pi = n − qi . A similar argument applies to Ms . It is now clear
that Algorithm B yields a binary images M having the binary image M1 with row projections
vi = (qi , ri ), i = 1, 2, . . . m as a prefix or as a suffix.
Example 3.
Input : s = 2, m = 4, n = 5; v1 = (2, 1), v2 = (2, 5), v3 = (2, 6), v4 = (2, 3)
An application of Algorithm B (which uses
images

1
 0

M1 = 
 0
1
Algorithm A in Step 1) constructs the binary
0
0
0
0
1
1
0
0
0
0
1
0
0
1
1
1





and



M2 = 

1
1
1
1
1
1
1
1
1
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
1
1
1



.

Note that the rows of M1 have the row projections (2, 1), (2, 5), (2, 6), (2, 3) while the rows of
M2 have the row projections (4, 2), (4, 10), (4, 12), (4, 6). The binary images M1 M2 and M2 M1
are the results of the output, given by



M1 M2 = 

1
0
0
1
0
0
0
0
1
1
0
0
0
0
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
1
1
1





527
Binary Image Reconstruction Based on Prescribed Numerical Information

1
 1

M2 M1 = 
 1
1
1
1
1
1
1
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
1
1
1
1
0
0
1
0
0
0
0
1
1
0
0
0
0
1
0
0
1
1
1





Both the binary images M1 M2 and M2 M1 have the row projections (6, 15), (6, 27), (6, 30), (6, 21).
4
Conclusion
Algorithms for the two problems of reconstruction of a binary image, given some numerical
information on the rows of the binary matrix representing the image, have been formulated
here. Reconstruction of binary polyominoes has been another problem of interest in discrete
tomography (see for example [24]) and the references therein). The applicability of the type
of problems and the algorithms considered here can be examined in polyomino reconstruction
problem.
Acknowledgements. The authors gratefully acknowledge the comments of the reviewers
which helped to improve the presentation of the paper.
References
[1] Balázs, P. Discrete tomographic reconstruction of binary images with disjoint components using shape
information. Int. J. Shape Modeling, 14: 189–207 (2008)
[2] Batenburg, K.J. Analysis and optimization of an algorithm for discrete tomography. Elect. Notes Disc.
Math., 12: 35–46 (2003)
[3] Brocchi, S., Frosini, A., Picouleau, C. Reconstruction of binary matrices under fixed size neighborhood
constraints. Theor. Comp. Sci., 406: 43–54 (2008)
[4] Brualdi, R.A. Algorithms for constructing (0, 1)-matrices with prescribed row and column sum vectors.
Discrete Math., 306: 3054–3062 (2006)
[5] Brunetti, S., Frosini, A., Picouleau, C. Reconstructing a binary matrix under timetabling constraints.
Electronic Notes in Discrete Mathematics, 20: 99–112 (2005)
[6] Brunetti, S., Del Lungo, A., Gritzmann, P., de Vries, S. On the reconstruction of binary and permutation
matrices under (binary) tomographic constraints. Theor. Comp. Sci., 406: 63–71 (2008)
[7] Costa, M.-C., Jarray, F., Picouleau, C. Reconstruction of binary matrices under adjacency constraints.
Electronic Notes in Discrete Math., 20: 281–297 (2005)
[8] Dahl, G., Brualdi, R.A. Matrices of zeros and ones with given line sums and a zero block. Electronic Notes
in Discrete Math., 20: 83–97 (2005)
[9] Frosini, A., Nivat, M. Binary matrices under the microscope: a tomographical problem. Theor. Comp.
Sci., 370: 201–217 (2007)
[10] Gale, D. A theorem on flow in net works. Pacific J. Math., 7: 1073–1083 (1957)
[11] Herman, G.T., Kuba, A.(eds.) Discrete Tomography: Foundations, Algorithms and Applications, Birkhuser,
1999
[12] Herman, G.T., Kuba, A. (eds.) Advances in Discrete Tomography and Its Applications, Birkhuston, 2007
[13] Kuba, A. Reconstruction of unique binary matrices with prescribed elements. Acta Cybernetica, 12: 57–70
(1995)
[14] Ozsvár, Z., Balázs, P. An empirical study of reconstructing hv-convex binary matrices from horizontal and
vertical projections. Acta Cybernetica, 21: 149–163 (2013)
[15] Masilamani, V., Krithivasan, K., Subramanian, K.G., Miin Huey, A. Efficient Algorithms for Reconstruction
of 2D-Arrays from Extended Parikh Images. Lect. Notes in Comp. Sci., 5359: 1137–1146 (2008)
[16] Masilamani, V., Krithivasan, K. Bi-level image reconstruction from its two orthogonal projections with
periodicity and a subimage constraint. Int. J. Imaging Sci. and Engineering, 2: 170–173 (2008)
[17] Mateescu, A., Salomaa, A. Matrix indicators for subword occurrences and ambiguity. Int. J. Found.
Comput. Sci., 15: 277–292 (2004)
[18] Mateescu, A., Salomaa, A., Salomaa, K., Yu, S. A Sharpening of the Parikh Mapping. Theoret. Informatics
Appl., 35: 551–564 (2001)
[19] Parikh, R.J. On context-free languages. J. Assoc. Comput. Mach., 13: 570–581 (1966)
528
[20]
[21]
[22]
[23]
K.G. SUBRAMANIAN, P. ISAWASAN, R. BUDIARTO, I. VENKAT
Ryser, H.J. Combinatorial propertiers of matrices of zeros and ones. Pacific J. Math., 9: 371–377 (1957)
Salomaa, A. Formal Languages, Academic Press, London, 1973
Salomaa, A. On the injectivity of Parikh matrix mappings. Fundam. Inf., 64: 391–404 (2005)
Subramanian, K.G., Huey, A.M., Nagar, A.K. On Parikh matrices. Int. J. Found. Comp. Sci., 20:
211–219 (2009)
[24] Tawbe, K. Two Subclasses of 2-convex Polyominoes: Properties For Reconstruction. Appl. Anal. Discrete
Math., 4: 136–155 (2010)
[25] Yasar, O., Diner, C., Dogan, A., Weber, G.W., Ozbudak, F., Tiefenbach, A. On the applied mathematics
of discrete tomography. J. Computational Technologies, 9(5): 14–32 (2004)