Method 2


The method used to detect the tank will be described using 2 particular images - one on the Duncan carpet, the other on the bricks. The original images are shown below.

Duncan:

Brick:

After the user specifies the image to be processed and the type of background, eroding and dilating is performed on the image to remove small peaks of noise and then a threshold is taken on the image. The brick and the duncan background has the same threshold, but the threshold for the dirt background is slightly higher. These are the images obtained after the threshold:

Duncan:

Brick:

As shown in the figures above, there is plenty of background "noise" after taking the thresholds - such as the speckles of the carpet or the reflected glare from the flash, or the vertical and horizontal lines between the bricks. We would like to clean the background up somewhat. In the case of brick backgrounds, the thick vertical and horizontal lines (spaces between bricks) are eroded away. Dilation is then done to restore the original size of the images. In the case of dirt and duncan backgrounds, a "for loop" is used to go though each "white" pixel of the image and calculate the amount of "white" pixels around it to determine whether or not to keep this particular pixel. This is somewhat like median filtering. The reason median filtering is not used is because it is very inefficient speed-wise. After cleaning up the background, the images look like

Duncan:

Brick:

After cleaning up the background, each object in the image is extracted from the image to be processed. The size of the image is first determined. The object would be eliminated as the possible target (in this case, a tank) if its size does not fall into a specific range. The rock and the tank of the "Duncan" image is shown below.

Rock:

Tank:

If an object's size falls within the range of the size of a tank, we then perform a "rectangular test" on it. This tests whether the shape of the object is a rectangle. The first step is to take off part of a corner of the image. If the part taken off has very few pixels in it, then the image cannot be a rectangle. This is done on all 4 corners. This is done to eliminate L-shaped or triangular objects. Then, edge detection (gradient method) is performed on the image, as shown in the figures below).

Edges of Rock:

Edges of Tank:

DCT is then performed. If an image has straight edges, they will show up on the DCT. The DCT of the rock and the tank is shown below. As you can see, the DCT of the rock has only a few pixels with high energy (since the rock has no straight edges). The DCT of the tank has a lot more pixels with high energy due to the straight edges.

DCT of Rock:

DCT of Tank:

Pixels at the top-left corner are then removed. In the case of the rock, almost all the pixels would be zero; however, there is still plenty of high energy pixels left in the DCT of the tank (after removing those at the top-left corner). Now, we count the number of high pixels. If there's plenty of them, then the object would very likely to be a tank.

Here's the output image of these two images:

Duncan Output:

Brick Output: