Mosaic Defect Detection Based on Macro Block Solid Edge Detection

: Mosaic defect detection is a common phenomenon of video defect in Digital video and will degrade the video quality. Therefore, it is more and more important to locate the mosaic and restore the video. Since the macro block is the smallest synchronization unit in the video image and mosaic is occurred in the form of macro block. A mosaic block detection method based on macro block edge detection is proposed in this study. First, the frame image is processed by canny edge detection algorithm to obtain the edge image. Second, the binary edge image is traversed by macro block and determines the solid edge of macro block; finally the mosaic block is determined according to the number of solid edges on every macro block. The experimental results show that the algorithm has good performance.


INTRODUCTION
With the development of information technology, there has been an explosion in the exploitation and availability of digital visual media.Generally, making video programs has to be experienced processes like shooting, capturing, editing, storing, transporting and so on.Video data in these processes need to be decoded and encoded for many times.Each link may occur error or loss of data, which will lead to degrade the video quality and many video images appear various failures, such as mosaic, fuzzy picture, disturbance, stripes, snowflakes, black screen and so on.In order to restore these video data, restore video images (Joyeux et al., 2001;Tenze et al., 2002;Kokaram, 1998;Kwatra et al., 2003), the first task is to locate these video failures.Mosaic detection is just discussed in this study.
The common defective images in TV programs are black, red, green and blue field, the static frame and the mosaic, etc (Sun et al., 2010).The first three are simple defects, relatively easy to detect, but mosaic phenomenon is a complex video defect.Compared to the first three kinds of defects, mosaic recognition is a difficult problem (Zhang et al., 2010).At present, there are two kinds of mosaic detection methods, which are based on regional analysis and edge detection.On the base of regional analysis, a detection method based on grid expansion is proposed in article (Ning and Feng, 2011), this method needs a large amount of computation and is not processed in real-time.In all methods which are based on edge detection, (Huang et al., 2008), first adopt a detection method based on support vector machine, it first uses Canny edge algorithm to detect one frame image of the video, Second, uses the template matching to find the candidate mosaic block coordinate.At last, a SVM classifier is employed to distinguish mosaic block from the candidate ones (Zhang et al., 2010).In the literature Huang et al. (2008) and Zhang et al. (2010) improved the matching template; propose a mosaic video detection method based on template matching.In order to speed up detection process, on the base of edge detection, a method of macro block solid edge detection is proposed in this study.The detailed processes include 4 steps, which are edge detection, macro block solid edge detection, mosaic block determination and the spread of mosaic solid edge.

CAUSES AND FEATURES OF MOSAIC
Mosaic is the phenomenon of regional distortion in the video; it is often caused by code error and packet loss.In general, the code stream of MPEG -2 encoded video is divided into 6 levels' hierarchy structure according to syntax.The 6 levels are the follows: the video sequence, the image group, the slice of macro block, macro block and pixel block, in which macro block is the smallest synchronization unit in the MPEG video images, MPEG video is block-based image   (Wang et al., 2005;Gallant and Kossentini, 2001).The so-called mosaic image in digital video is just the error based on block or strip.
Therefore, after summarizing the reasons of mosaic occurrence, the mosaic has the following characteristics: • The correlation of micro domain, mosaic is the distortion caused by decoding error, so the resulting mosaic is occurred in the form of macro block.
Since the common encoding macro block is 16 pixels, the resulting mosaics are mostly ruled blocks and strip areas which are often the integral multiple of 16 pixels.• The discontinuity of the macro domain, the causes of mosaic is most circuit lines problems and equipment failures.Therefore, mosaic's occurrence often appears intently and suddenly.The distribution of mosaic block is the relatively concentrated, there exists a mosaic region and nonmosaic region, the mosaic's internal and external pixel values are quite different, but the margin between regional mosaics will become blurred.
Figure 1 and 2 are a frame of normal image and a frame of mosaic image respectively that are taken from a video, through comparing these two images, the features of mosaic image described in the above can be easily found.

MACRO BLOCK SOLID EDGE DETECTION
Edge detection: The edge of the image is a collection of the image's pixels.Its pixels' grayscale often has a significant change and the collection of these pixels is often closed curves.The curve has concentrated most information of the image.Therefore, the determination and extraction of image's edges is very important for the recognition and understanding of the entire image.A better edge detection algorithm canny operator is used in this study to extract the edge information of a picture (Canny, 1986).
The implementation of canny algorithm can be divided into 7 steps: Step 1: Generate Gaussian function by the Gaussian filter coefficients.Two-dimensional zero -mean discrete Gaussian function can be regarded as the smoothing filter, the formula is as follows: In the formula (1), is the variance of Gaussian function, it is the width of Gaussian filter, determines the smoothness.
Step 2: Smooth the original image by the generated Gaussian filter function .Gaussian filter is linear filter and can be described by the convolution: In Eq. ( 2), H(x, is Gaussian function, f(x) is the original image and G(x is the smoothed image.
Step 3: Calculate the gradient of the filtered image.The image is considered as a two-dimensional discrete function, the image's gradient is the derivative of this two-dimensional discrete function.The gradient's magnitude and direction are calculated by the finite difference of first-order partial derivative.The amplitude and direction of the gradient are given by Formula 6 and 7, respectively.
Step 4: Non-maximum value suppression on the gradient.The edge is confirmed by the magnitude and direction of the gradient.The value of the gradient's direction is from-22 to 157.It is divided into 4 combinations, these four combinations corresponds to the 3×3 neighborhood of the image, as shown in Fig. 3, the 4 combinations of the directions are: the up and down, the left and right, the upper left and the lower right, the upper right and the lower left.The pixel gradient's direction is corresponding to these four combinations.Calculate 2 pixels' gradient values in each combination.If the value of the center pixel's gradient is smaller than the gradient values of the 2 adjacent pixels along the gradient Figure 4 shows the four combinations of gradient's direction and the corresponding 3×3 neighborhood image of the image.
Step 5: Add up the histogram of the image and determine the threshold.
Step 6: Find the starting point of the edge boundary using a function.
Step 7: According to the results performed in step 6, start to search from a pixel and search all the boundary points whose starting point is this pixel.
The edge detection results of Fig. 1 and 2 are Fig. 5 and 6 respectively.

Solid edge detection:
In this study, the solid edge is defined as clear edge in the macro blocks and can be acted as the determination of mosaic block.The method of solid edge detection is as follows: First, suppose the binary edge image's width and height is W and H.The size of every macro block is 16 × pixels and then the image is divided into some macro blocks.And every block in the image is traversed to determine which one in the four edges of every block is detected as solid edge.The method of the solid edge determination is as follows: Suppose T is the threshold of edge detection, the four edges of the macro block are detected, respectively.Suppose N represents the pixel number of one edge, if N>T, then this edge is considered as solid edge, mark this edge as solid edge, otherwise, it is not solid edge.
According to the edge detection results, the type of macro block's edges can be divided into 5 types.As shown in Fig. 7.

MOSAIC DETECTION
Mosaic block determination: If the number of a macro block's solid edges is more than 3, then mark this block as mosaic block, such as Type 4 and Type 5.If the macro block's type is like 1, 2, 3, then it is not mosaic block.
The spread of mosaic solid edge: For the most time, the common edge between adjacent mosaics is blurred.And it is likely to be judged as non-solid edge in the edge detection process.As shown in Fig. 3.A has three solid edges, B has two solid edges, A is determined as mosaic block while B is determined as non-mosaic block.In fact B is also the mosaic block and then there will be false judgment.So in this case, it is handled as follows: First, if a macro block is marked as mosaic block and its edges' number is less than 4, then its non-real edge is marked as the solid side and its neighboring macro block should be rechecked.
Therefore, in graph 8, after determining A as mosaic image, B should be redetected.B has three solid edges, so B is marked as the mosaic macro block.Mosaic frame detection: When the mosaic macro block's number in a video frame is greater than the macro block's number threshold, this frame is marked as mosaic frame.

EXPERIMENT RESULTS AND ANALYSIS
In order to verify the effectiveness of the method proposed in this study, actual video which contains mosaic is used in this experiment, one frame image is captured every 2 seconds.And 500 frames of mosaic image are got from the video and being tested.The test sets consist a variety of cases, including frame with MB and frame without MB.The frame size is 720×576 pixels.The smallest edge of a mosaic is set as 16 pixels, the threshold of edge detection is set as10 pixels and the threshold of mosaic block is set as 4.The above algorithm is tested in Visual Studio 2008 and Opencv 2.0.Comparing to the classical method based on SVM and template matching, the experiment results are as follows: In Table 1, recall and false alarm rate are used to evaluate the algorithm.Recall rate is the percentage of real frame with MB detected as mosaic frame.False alarm rate is the percentage of frame without MB detected as mosaic frame.
In order to compare the detection performance of the algorithm proposed in this study and the detection method based on SVM and template matching, the 500 frame images are divided into 5 groups, which means that the detection process consists 5 stages, after each stage is completed, record the whole number of frames without mosaic detected as mosaic frames.The details are showed in Fig. 8.
Table 1 and Fig. 8 can easily show that the algorithm in this study is more accurate than the algorithm based on SVM and template matching.Besides, considering the complexity computation in these two algorithms, it is obviously seen that the algorithm proposed in this study is simpler than the algorithm based on SVM and template matching.So, for the consideration of efficiency or accuracy rate, mosaic detection method based on macro block solid edge detection has high accuracy rate, fast corresponding

Fig. 8 :
Fig. 8: Comparison of numbers of frames without mosaic detected as mosaic frames of the two algorithms speed and can meet the real-time requirements in practical application.CONCLUSIONA new video mosaic detection method is proposed in this study.It is based on the macro block solid edge detection and its advantages are as follows:• Compared to the video mosaic detection method based on SVM and template matching, it is faster with low complexity and does not need data training • It is simple and efficient.When the mosaic in the video is relatively obvious, the correct detection rate can reach 100% • It is well compatible with low performance processors' running environment

Table 1 :
Test results