This example shows how to use the For Each Subsystem block to process submatrix data when neighboring submatrices overlap each other. To demonstrate this data processing approach, the example implements image edge detection with linear filters using the For Each Subsystem block. Each For Each Subsystem block has a For Each block that needs to be configured for partitioning and concatenation.
Open the example model
slexForEachOverlapExample. This model uses a 3-by-3 kernel to implement the edge detection application for a given two-dimensional image. Because of the two-dimensional input signal, this example uses nested For Each subsystems.
The outer For Each subsystem partitions the signal along the first dimension. The outer For Each block is configured to partition the input signal along dimension 1. The block specifies a partition width of 3 and a partition offset of -2. (A partition offset of -2 indicates that each slice overlaps its neighboring slices by 2 elements.)
The inner For Each subsystem partitions the signal along the second dimension. The inner For Each block has the same settings as the outer For Each block, except that the inner block is set to partition and concatenate signals along dimension 2.
The partitioning order is arbitrary. To ensure correctness of the result, the concatenation order of the outputs follows the partitioning order.
For simplicity, this example does not handle data padding. As a result, the size of the output image is slightly smaller than that of the input image.
The result of the comparison between the original image and the processed image is shown below.
Figure 1: Original image vs. processed image