Model of Random Field with Piece-Constant Values and Sampling-Restoration Algorithm of Its Realizations

We propose a description of the model of a random piecewise constant field formed by the sum of realizations of two Markov processes with an arbitrary number of states and defined along mutually perpendicular axes. The number of field quantization levels can be arbitrary. Realizations of a random field model of the desired shape are created by appropriate selection of parameters for formative realization of Markov processes. For the proposed field model, we investigated the sampling and restoration algorithm of any selected realizations. As a result, we determined the optimal sampling and recovery algorithms. The resulting sampling is fundamentally non-periodic. Recovery errors are calculated. Two examples are considered.


Introduction
In image processing, the first operation performed on a specific plot in most cases is level quantization. The number of levels depending on the objectives of the study may be different. The second operation is to sampling of the quantized plot using Cartesian (or polar) coordinates. The problems that arise here are typical for the sampling-recovery algorithms (SRA) of realizations of random fields; it is necessary to determine based on a priori information about the image and selected criteria, the optimal sampling-recovery procedure and then evaluate the quality of restoration.
Gaussian models of random fields are the simplest, because for multidimensional distributions of random variables, the analytical expressions representing a priori information about the field are known. The situation with non-Gaussian field models is fundamentally different, since the analytical description becomes very complicated and the level quantization operation only aggravates the situation. This circumstance explains the fact that the number of real images being analyzed is constantly growing, see [1][2][3] etc.
Various models of the random fields, the realizations of which are quantized by level and sampled on a plane, are known in the literature (see, for example, the fundamental books [4][5][6][7][8], as well as the journal articles [9][10][11][12][13][14]. However, the authors of the present article are not aware of any works discussing the statistical models of random non-Gaussian fields with a finite number of states (i.e., analytical field models after a quantization). In addition, there are no publications devoted to the SRA description of realizations of such fields. The proposed work is intended to remedy the aforementioned shortcomings.

Description of the Model of a Random Field with Piecewise Constant States
We form a random piecewise-constant field ζ(t, s) by summing two independent homogeneous Markov processes ξ(t) and η(t) ς(t, s) = ξ(t) + η(s) The processes ξ(t) and η(s) have continuous arguments and discrete sets of states (let it be the sets X = x i , i = 1, 2, . . . , N ξ − 1 and Y = y j , j = 1, 2, . . . , N η − 1 which are defined on the axes t and s. Hereinafter, it is convenient to perceive t and s as time axes. N ξ , N η are the numbers of states of the corresponding processes. We do not introduce special notation for realizations of random functions that are different ξ(t), η(t) and ζ(t), therefore Equation (1) will also be understood as the sum of realizations. The Markov property of formative processes allows an analytic description of the structure of such a field. It might be possible to abandon the Markov properties of the generating processes, but this significantly complicates the analytical description of the SRA (for comparison, see, for example, [24]).
It is assumed that the characteristics of the processes ξ(t) and η(s) (the output density and the transition probability) are known. Denote the output density (or output intensity) of the states: for ξ(t) : λ ξi , i = 1, 2, . . . , N ξ − 1, for η(s) : λ ηj , j = 1, 2, . . . , N η − 1 the meaning of which is tat: P go out from the state x i during the interval ∆t = λ ξi ∆t + o(∆t) P go out from the state y j during the interval ∆s = λ η j ∆s + o(∆s) We also assume that for ξ(t) and η(s) there are given graphs or transition probability matrices P ξ = [p ik ], P η = q js . Figure 1 shows examples of realizations of fields formed by the sum Equation (1). The number of levels according to the values of each function in Figure 1a-c is 10 (a total of 19 field levels). High intensity of red color means the maximum value of the field, and high intensity of blue color minimum. Figure 1a-c illustrate the flexibility of the proposed model. It is possible to form various realizations of the random field by selecting the parameters of the generating realizations. Specifically, it is possible to create field realizations with a fairly large area where there are no transitions. Such areas can be in the center (Figure 1a) or shifted in any direction (Figure 1b shows an upward). It is also possible to simulate two maxima (Figure 1c). Small areas with different sizes can be created around such areas, and so on. The Figure 2 shows a field with a maximum at the center (similar to Figure 1a) with a coarser quantification 8 levels for field values.
We form a random piecewise-constant field by summing two independent homogeneous Markov processes ( )   (1) will also be understood as the sum of realizations. The Markov property of formative processes allows an analytic description of the structure of such a field. It might be possible to abandon the Markov properties of the generating processes, but this significantly complicates the analytical description of the SRA (for comparison, see, for example, [24]).
It is assumed that the characteristics of the processes ( )    Figure 1a-c is 10 (a total of 19 field levels). High intensity of red color means the maximum value of the field, and high intensity of blue color minimum. Figure 1a-c illustrate the flexibility of the proposed model. It is possible to form various realizations of the random field by selecting the parameters of the generating realizations. Specifically, it is possible to create field realizations with a fairly large area where there are no transitions. Such areas can be in the center (Figure 1a) or shifted in any direction (Figure 1b shows an upward). It is also possible to simulate two maxima (Figure 1c). Small areas with different sizes can be created around such areas, and so on. The Figure 2 shows a field with a maximum at the center (similar to Figure 1a) with a coarser quantification 8 levels for field values.

Description of the Sample-Recovery Algorithm of the Realization of the Field Model
Unrecoverable errors associated with the omission of states may occur in the sampling of realizations of processes with piecewise constant states. Such errors occur in the case when the duration of the process in the state is less than the sampling interval. The SRA of realization of the processes under consideration should take into account this phenomenon. Namely, it is necessary to determine the SRA so that when recovering, the probability of skipping a state is no more than a given level γ [22,23]: This post expresses the idea of the condition: "it is advisable not to skip states". A similar requirement must be met when analyzing the SRA of a random field ( ) samples of the field realization, one must not only estimate the position of the switching points of the process realizations, but also determine the states of the processes themselves. The latter circumstance is important because the residence time of the process in a given state and the sampling interval depend on the state itself. We emphasize this circumstance, since sampling turns out to be fundamentally non-periodic.
To determine the realizations of ( ) Then at an arbitrary point * t of the t axis one can write:

Description of the Sample-Recovery Algorithm of the Realization of the Field Model
Unrecoverable errors associated with the omission of states may occur in the sampling of realizations of processes with piecewise constant states. Such errors occur in the case when the duration of the process in the state is less than the sampling interval. The SRA of realization of the processes under consideration should take into account this phenomenon. Namely, it is necessary to determine the SRA so that when recovering, the probability of skipping a state is no more than a given level γ [22,23]: This post expresses the idea of the condition: "it is advisable not to skip states". A similar requirement must be met when analyzing the SRA of a random field ζ(t, s). Below, in Section 4, we detail the condition Equation (2) is detailed.
The description of the SRA realizations of the field ζ(t, s) is associated with the analysis of the SRA realizations of the generating processes ξ(t) and η(s). At the same time, knowing the samples of the field realization, one must not only estimate the position of the switching points of the process realizations, but also determine the states of the processes themselves. The latter circumstance is important because the residence time of the process in a given state and the sampling interval depend on the state itself. We emphasize this circumstance, since sampling turns out to be fundamentally non-periodic.
To determine the realizations of ξ(t) and η(s) from known values of the field ζ(t, s), it is enough to know its value at one point of one of the formative realizations (ξ(t) or η(s)). For example, if at some point s * the value η * = η(s * ) is known, then by Equation (1) we have Then at an arbitrary point t * of the t axis one can write: The possibility of unambiguous recovery depends on the sets of states of the formative processes and on the specific states used in a given field realization. There may be situations where recovery is trivial. For example, let the process ξ(t) have d states: x i = i∆, i = 1, 2, . . . , d − 1 (∆ is the measurement discreteness; we take ∆ = 1) and the process η(s) has M states: y j = j∆, j = 0, 1, 2, . . . , M − 1. Table 1 shows the values of the function z(x, y) = x + y for arbitrary d and M. Table 1.
Values z = f (x,y) = x + y for arbitrary d and M, total N = dM values.    Table 3. Field values at M = 4 states.
The possibility of unambiguous recovery depends on the sets of states of the formative processes d on the specific states used in a given field realization. There may be situations where recovery is ivial. For example, let the process In particular, for , it turns out 16 dM = field levels. The values of this function are iven in Table 2.  Table 3. Field values at M = 4 states.
The possibility of unambiguous recovery depends on the sets of states of the formative processes and on the specific states used in a given field realization. There may be situations where recovery is trivial. For example, let the process In particular, for , it turns out 16 dM = field levels. The values of this function are given in Table 2.  (3) and (4). Table 3. Field values at M = 4 states.
Finally, the application Equation (1) yields The possibility of unambiguous recovery depends on the sets of states of the formative processes and on the specific states used in a given field realization. There may be situations where recovery is trivial. For example, let the process In particular, for , it turns out 16 dM = field levels. The values of this function are given in Table 2.  (3) and (4). Table 3. Field values at M = 4 states.
Finally, the application Equation (1) yields The possibility of unambiguous recovery depends on the sets of states of the formative processes and on the specific states used in a given field realization. There may be situations where recovery is trivial. For example, let the process In particular, for , it turns out 16 dM = field levels. The values of this function are given in Table 2.
In particular, for  Table 2.
In particular, for d = M = 4, it turns out dM = 16 field levels. The values of this function are given in Table 2. In the examples, all values of the function z = f (x, y) = x + y are different, and therefore each field value corresponds to a single pair (x, y), so restoring the realizations of the processes ξ(t) and η(s) is trivial.
The situation when the process state grids have the same step is quite important. For example, let the processes ξ(t) and η(s) have N integer states: x i = i, y j = j; i, j = 1, 2, . . . , N − 1. The values of the sum with N = 4 are shown in Table 3. It is clear that if the field has the values 1, 2, 3 or 5, then the value of the pair (x, y) is not uniquely determined. If the value of the field is 0 or 6, then the value of the pair (x, y) is uniquely determined, and therefore the realizations ξ(t) and η(s) are determined in accordance with Equations (3) and (4).
where (x min , y min ), (x max , y max ) are the minimum and maximum values of the sets X and Y.
The sufficiency is obvious, since each of these values corresponds to a single pair: (x min , y min ) for ζ min , and (x max , y max ) for ζ max , and then by Equations (3) and (4) the realizations ξ(t) and η(s) are restored.
The necessity: from the uniqueness follows the fulfillment of condition Equations (5) and (6). Suppose that none of the conditions Equations (5) and (6) is satisfied, i.e., among the values (ξ, η) there is neither a point (x min, y min ), nor a point (x max , y max ). Or else, this condition is written differently: for any value (ξ, η) = (x, y), and show that recovery is not unique. Indeed, the available values of z = ζ(ξ, η) fields are obtained by summing some values of x i and some values of y j , and therefore the system of algebraic equations relatively unknown terms x 1 , x 2 , . . . , y 1 , y 2 , . . . is solvable by construction (the question is whether the solution is unique). Let be x 1 , x 2 , . . . , y 1 , y 2 , . . . that generate the available values of ζ ij field. Condition Equation (8) (the absence of two "necessary" points (x max , y max ) and (x min , y min )) is satisfied only in two cases: all x i ≥ x min + 1 and all y j ≤ y max − 1, all x i ≥ x min + 1 and all y j ≤ y max − 1, or all x i ≤ x max − 1 and all y j ≥ y min − 1.
These two situations are illustrated in Figure 3a,b. We form a new solution by marking the values with strokes. If Equation (9) is true, then from each x i we subtract 1, and to each y j we add 1: It is clear that x 1 , x 2 , . . . , y 1 , y 2 , . . . also satisfies system Equation (8), and in the Figure 3, the range of values a) goes to region b).
If true Equation (10), then we add to each x i 1 and subtract 1 from each y j : x i = x i + 1, y j = y j − 1.  These values also satisfy system Equation (8), while in Figure 3 the domain of (b) goes into region (a). Thus, if condition Equations (5) and (6) is not satisfied, then the solution is not unique. The necessity is shown.
Note that if the uniqueness condition is not satisfied, then the restoration is possible up to These values also satisfy system Equation (8), while in Figure 3 the domain of (b) goes into region (a). Thus, if condition Equations (5) and (6) is not satisfied, then the solution is not unique. The necessity is shown.
Note that if the uniqueness condition is not satisfied, then the restoration is possible up to constants, and this is quite acceptable in many practical situations.
So, the necessary and sufficient condition for the uniqueness of the recovery of formative realizations ξ(t) and η(s) is the existence (among the values of a given field realization) of an least one extreme value ζ * (ζ max or ζ min ) of a field that can be represented by the sum in the only way: where X and Y are the sets of the states of the processes, respectively, ξ(t) and η(s).
The sampling procedure consists of the following: (1) Determining the values ζ * , ξ * , η * among the given field values together with the corresponding values of the arguments t * and s * . (2) The definition of formative realizations ξ(t) and η(s) by Equations (3) and (4).
(3) Calculation of sampling intervals T ξ n and T η m along the t and s axes and sampling points: The sampling results are sets of values (t 0 , ξ 0 ), (t 1 , ξ 1 ), . . . , (t n , ξ n ), . . . The field recovery procedure consists of the following actions: (1) Restoration of realizations ξ v (t) and η v (s) by the values of ξ n and η m , n, m = 1, 2, . . . ; (2) Determining the recovered values of the ζ v (t, s) field in accordance with Equation (1):

Determination of Sampling Intervals
SRA for realization of Markov processes with a finite number of states are described in [22]. Let a continuous time Markov process have states 0, 1, 2, . . . , N − 1 with the corresponding exit from states intensities λ 0 , . . . , λ N−1 and the matrix of conditional probabilities P = p ij (on the diagonal p ii = 0). Let θ i be the duration of being in state i, and θ j be the duration of being in the next state j. By the property of a Markov process, the random variables θ i and θ j are independent and distributed according to the exponential law with the parameters λ i and λ j with density and with the corresponding distribution function F(x, λ).
At a sampling instant t n , it is necessary to determine the next instant t n+1 = t n + T n , i.e., determine the sampling interval T n , which is selected from the condition Equation (2) of a given small probability γ of a gap following the state i unknown state j. Next, we will use the property of the exponential distribution: the conditional distribution of the remainder of the transition does not depend on the elapsed waiting time and coincides with the distribution of the time in the state. The event "skip of state" (mentioned in Equation (2)) means that we have a condition: for any j, for which p ij > 0, i.e., the maximum of the probability in j must be equal to γ: where F (T; i, j * ) is the distribution function of the sum = θ i + θ j . Obviously, the greater λ j is, the less is θ j . Equation (13) reaches its maximum in that state j * = j * (i), at which λ j is maximal: The distribution function of the sum Σ = θ i + θ j * is equal to F Σ x; λ i .λ j * . Note that λ i and λ j * enter this expression symmetrically, which allows us to move to a one-parameter family of functions. Denote It is easy to show, the probability density of a random variable α is determined by formula: Then for a random variable αΣ, the distribution function, depending on the parameter k, as is easily shown [23], is equal top Condition Equation (13) takes the form: From Equations (16) and (17), one can find the value of the sampling interval: where F −1 α (γ, k) is the function inverse to F α (αT, k) with respect to the first variable (the monotonic increase in x of the function F α (αT, k) is taken into account). Note that the dependence of the interval T on i appears through α and k. The graphs of functions F −1 α (γ, k) [23] depending on the parameter k for different γ are shown in Figure 4. There is also an approximate solution of Equation (16) for T obtained by expanding in powers of small x [23]: The quality of the approximation Equation (19) with respect to the exact solution is no worse than 10% at γ < 0.03, [23].  The quality of the approximation Equation (19) with respect to the exact solution is no worse than 10% at 0.03 γ < , [23]. The least favorable next state, according to Equation (14), is the state with the number ( ) We calculate the quantities , α β and k by the relation Equation (17), and the value Let at the sampling instant t n the sample to have the value The least favorable next state, according to Equation (14), is the state with the number j * = j * (i). We calculate the quantities α, β and k by the relation Equation (17), and the value T ξ n = T(i, γ) is selected by the Equation (18). Then the next sampling time is determined in an obvious way Note that the functions j * = j * (i) and T(i, γ) are calculated in advance. The sampling of η(s) is performed similarly. Sampling results are sequences of pairs (t n , ξ n ), n = 0, 1, 2, . . . and similarly (s m , η m ), m = 0, 1, 2, . . .

Results Recovery of Formative Realizations from Discrete Samples
Consider the realization of the process on the axis (0, t) and denote on it the sampling points that need to be determined: t 1 , . . . , t n , t n+1 , . . . ; t n+1 = t n + T ξ n , t 0 = 0. Suppose that on the sampling interval t n + T ξ n there is a transition from state i to state j: ξ(t n ) = i ξ(t n + T) = j (here T = T ξ n ). It is required to estimate the unobservable value τ-the random istant of transition from i to j. The best estimate (in terms of minimal error variance) is the expectation of conditional distribution τ, provided that τ ∈ (t n , t n + T). Due to the homogeneity of the process, we assume that τ ∈ (0, T). The density of the conditional distribution of the point τ on the interval (0, T) provided that there is only one transition in the interval, is determined by the following relation [23]: where µ ξ ≡ µ ξ (i, j) = λ ξ i − λ ξ j . Equation (20) describes a truncated exponential distribution, which in the case µ ξ = 0 degenerates into a uniform one. By density Equation (20), the conditional expectation is determined, which is an estimate τ with the minimum variance for the transition instant τ: where indicated: u = µ ξ (i, j)T, We can verify that g(u) is an odd function and g(0) = 0. Specifically,τ the expression for the variance of the estimate is Graphs of the relative values of the estimateτ/T = [0.5 + g(u)] and the standard deviation σ = √ Vτ/T, as functions of the argument u = µT are shown in Figure 5.
For the process  Using Equation (22), we obtain the estimated values for the process switching points. The restoration is performed according to the values ξ n , η m ; n, m = 1, 2, . . . , measured in accordance with Equation (12).
For the processes ξ(t): if the interval (t n , t n+1 ) is the switching interval, i.e., ξ n ξ n+1 , then we determine the value of the estimate of the transition point ϑ t k using the Equation (22): where k is the sequence number of the switching interval on the t axis, k = 1, 2, . . . The value of the recovered realization ξ v (t) at the point t of the next interval is determined by the relation: For the process η(s): if the interval (s m , s m+1 ) is the next transition interval, i.e., η m η m+1 , then we determine the value of the transition pointθ s k estimate using Equation (22): in Equation (22), instead µ ξ we use µ η ≡ µ η (i, j) = λ ηi − λ ηj , i j; instead T = T ξ we use T = T η ; k is the sequence number of the transition interval on the s axis, k = 1, 2, . . . The values of the reconstructed realization at points s are as follows: For the recovered realizations of the processes ξ v (t) and η v (s) we determine the reconstructed value of the field realization by Equation (1):

Example 1. No Skip of State When Sampling
Let the process ξ(t) have 4 states: 0, 1, 2, 3, the process η(t) − 5 states: 0, 1, 2, 3, 4. The transition graph of the process ξ(t) is shown in Figure 6. These arrows show transitions in a way to indication of density. It is assumed that for internal states "1" and "2" transitions are possible only in neighboring states, and with equal probabilities.  Figure 6. These arrows show transitions in a way to indication of density. It is assumed that for internal states "1" and "2" transitions are possible only in neighboring states, and with equal probabilities. The density of exit from the states and the average duration of stay in the states are shown in Table 4. Average stay 1.0 1.  The process graph η(t) differs only in the number of states and values of the output densities. The density of exit from the states and the average duration of stay in the states are shown in Table 4.  The sum z = x + y can take 8 integer values from 0 to 7. If it is 0 or 7, then the pairs are determined uniquely: for z = 0 it is (0, 0), for z = 7 it is (3,4). Figure 7 shows the original field on a 10 × 10 square with 8 color levels. Vertically, there are 5 intervals of constancy, and horizontally-7; total 5 × 7 = 35 rectangles for which the field values, are given in the matrix Z with a size of 5 × 7.  Among the field values we find the value z max = 7, i.e., x max = 3, y max = 4 at the point t * = 5, s * = 9, and also one value z min = 0 at the point t * = 1, s * = 1. To recover ξ(t) and η(s), one point is enough t * = 5, s * = 9 with z max = 7, which means that ξ * (t) = ξ(t * = 5) = 3 and η * = η(s * = 9) = 4. Then by Equations (3) and (4), we have (these are the values of the top row of the matrix minus 4), η(s) = ς(t * , s) − ξ(t * ) = ς(5, s) − 3 (these are the values from the bottom up to the middle column of the matrix minus 3). Realizations ξ(t) and η(s) are shown in Figure 8. The corresponding state sequences are as follows: for ξ(t) − 0, 1, 2, 3, 2, 1, 2; for η(s) = 0, 1, 2, 3, 4.
The sampling intervals are obtained by Equations (14), (17) and (18). The sampling intervals are obtained by Equations (14), (17) and (18). For ξ(t), we have the states 0, 1, 2, 3, for which we write out the values of the sampling intervals T ξ for various values of the permissible probability γ of omission (see Equation (2) For convenience of illustration the value of the skip probability is γ = 0.05, which gives extended sampling intervals. In Figure 9 shows sampling and reconstruction for ξ(t)) and η(s); reconstructed realizations are depicted by dashed lines. Figure 10 shows the restored field. In this example, no state was skipped during sampling.  Figure 10 shows the restored field. In this example, no state was skipped during sampling.

Example 2. There is a Skip of State When Sampling
Consider an example close to the previous one, which differs from it only by the formative The new realization is shown in Figure 11, where it is noticeable that the second left vertical bar is very narrow. State 1 in the interval (0, 2) is skipped (Figure 12) when performing a sample. For this reason one column of rectangles disappears in the restored field realization of Figure 13. Their number became six instead of seven. This is a characteristic error of a special type, which is governed by the choice of value γ.

Example 2. There is a Skip of State When Sampling
Consider an example close to the previous one, which differs from it only by the formative realization ξ(t). The new realization is shown in Figure 11, where it is noticeable that the second left vertical bar is very narrow.
State 1 in the interval (0, 2) is skipped ( Figure 12) when performing a sample. For this reason one column of rectangles disappears in the restored field realization of Figure 13. Their number became six instead of seven. This is a characteristic error of a special type, which is governed by the choice of value γ.  We draw attention to the fact that the values found for the sampling intervals of the forming realizations turned out to be different for different states.  We draw attention to the fact that the values found for the sampling intervals of the forming realizations turned out to be different for different states.  We draw attention to the fact that the values found for the sampling intervals of the forming realizations turned out to be different for different states. We draw attention to the fact that the values found for the sampling intervals of the forming realizations turned out to be different for different states.

Conclusions
A model of a random field is proposed that is formed by summing two formative realizations of piecewise constant Markov processes with an arbitrary number of states. The flexibility of the field model is associated with the possibility of choosing the number of quantization states, as well as the expedient assignment of probabilistic characteristics of two formative realizations to obtain realizations of the field of the desired shape (for example, the presence of relatively large areas without jumps, their location in the field of view, etc.). This article has developed a sampling-restoration algorithm of the proposed random field model. We derive for the field type under consideration, the necessary and sufficient condition for the unambiguous recovery of formative realizations from field values. We substantiate the choice of sampling intervals with a given probability of missing state. Discrete samples are used to estimate random moments of transition from one state to another as well as the variance of the estimates.
The article has developed a sampling-restoration algorithm of the proposed random field model. We obtain for this model the necessary and sufficient condition for the unambiguous recovery of formative realizations from the field´s values. The choice of sampling intervals with a given probability of skipping a state is justified. On discrete samples, random instants of transition from one state to another are estimated, and the estimates of variance are calculated. Two examples are given to illustrate the proposed algorithms.
The proposed model can be used for modeling the various quantized by level fields. It is possible to select the number of quantization levels, as well as the formation of field realizations with the desired features.

Conflicts of Interest:
The authors declare no conflict of interest.