CSE/EE 485:  Digital Image Processing I

Computer Project Report # : Project 1

Image Transformation Using Boolean Operations / Component Analysis

Group #4: Isaac Gerg, Pushkar Durve

Date: September 25, 2003


A.  Objectives
  1. Study the effects of Boolean operations on binary images.
  2. Study the effects of the Matlab MAX operator on quantized gray level images.
  3. Study the effects of image differencing including absolute difference and ordinal difference.
  4. Learn to implement the BWLABEL function to compute an image's connected components.
  5. Formulate real-world applications which utilize the above functions.
B. Methods
There are two 'M' files for this project. The M file concerning Boolean operations and image differences is called project1a.m. The M file concerning connected-components is called project1b.m.

project1a.m contains five parts.

A, B are image objects.

1. Computing of A AND B.
2. Computing of A XOR B.
3. Computing of [NOT (A) XNOR NOT (B)]
4. Utilization of MAX operator on two quantized gray level images.
5. Utilization of the IMSUBTRACT and IMABSDIFF functions.

project1b.m contains 1 part

1. Connected-component analysis using generated image via CHECKERBOARD function along with the BWLABEL function.

Executing project1a.m from Matlab

At the command prompt enter:

>>project1a

Executing project1b.m from Matlab

At the command prompt enter:

>>project1b

 

C. Results
Image file names in parentheses.


Results described in order following Methods section above.

Figure 1: One of the two original binary images of which we performed Boolean operations. (checker.gif) Figure 2: The second image of the two original binary images of which we performed Boolean operations (castles.gif)

Part 1
This image was realized by AND'ing the Figure 1 with Figure 2. A bit by bit Boolean AND operation was performed and yielded the following image: (Figure 3)


Figure 3: Figure 1 ANDed with Figure 2. (image_AND.jpg)

Figure 3 was as expected as both images must contain a corresponding white pixel to realize a corresponding white pixel in the final image, Figure 3.


Part 2
This image was realized by XOR'ing the Figure 1 with Figure 2. A bit by bit Boolean XOR operation was performed and yielded the following image: (Figure 4)

 


Figure 4: Figure 1 XORed with Figure 2. (image_XOR.jpg)

Figure 4 was as expected as both images must contain different corresponding pixels to realize a corresponding white pixel in the final image, Figure 4.

Part 3
Let A, B be of type image. Let A be Figure 1 and B be Figure 2. The Boolean operation performed is: [NOT(A) XNOR NOT(B)]. The output is realized in Figure 5.

Figure 5: [NOT(A) XNOR NOT(B)]. (image_XNOR.jpg)

By following a truth table it was determined that our complex Boolean function operated correctly.

Part 4
Two images were combined using the MAX operator. This operator assigns the maximum of a pixel pair to a new image, Figure 8. This function operates on quantized gray level images.

Figure 6: (lenna.gif)

Figure 7: (lv40.gif)

Figure 8: MAX operation performed from Figures 6, 7. (image_max.jpg)

Part 5
Two consecutive video frames were compared using the IMSUBTRACT and IMABSDIFF functions. These types of functions are commonly used in motion detection, image compression as in the case of MPEG 1, and object tracking. See the figures below.

Figure 9: First frame of sampled video sequence. (seq1_frame_0001.gif)

 

Figure 10: Second frame of sampled video sequence. (seq1_frame_0002.gif)
Figure 11: Subtraction of Figure 9 from Figure 10 (imsubtract_image.jpg) Figure 12: Absolute difference of Figure 9 and Figure 10 (imabsdiff_image.jpg)

These difference mechanisms may track live motion as shown above. Motion among the human figures is highly probable given the context of the source images and the setting they depict.

Connected-Components Analysis

A checkerboard patterned image was created using the CHECKERBOARD function. This image was used as our test image (checkerboard.png). Then, we applied the BWLABEL function to our image object of the checkerboard to determine the number of connected objects in the image object. We performed an analysis of 4 and 8-connectivity.

Figure 13: The test image used for 4 and 8-connectivity analysis.
The true image size is 8x8 pixels. It is shown scaled here. (checkerboard.png)

The results of our analysis are below:

connected_components_4 =

0 5 0 13 0 21 0 29
1 0 9 0 17 0 25 0
0 6 0 14 0 22 0 30
2 0 10 0 18 0 26 0
0 7 0 15 0 23 0 31
3 0 11 0 19 0 27 0
0 8 0 16 0 24 0 32
4 0 12 0 20 0 28 0
 

Figure 14: The output of BWLABEL for 4-connectivity.

.

connected_components_8 =

0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0

 

Figure 15:The output of BWLABEL for 8-connectivity.

As expected, there is only one connected component for 8-connectivity and 32 for 4-connectivity.

In 4-connectivity, none of the white pixels are contained within another white pixels N4 set. Therefore each white pixel is its own connected component therefore having 32 connected components because there are 32 white pixels in an 8x8 checkerboard image.

In 8-connectivity, all of the white pixels are contained within another white pixels  N8 set. Therefore each white pixel is connected to every other white pixel. The  N8 set has four more degrees of freedom that  N4. As expected, there are less connected components realized in 8-connectivity.

 N4 = {(x+1,y), (x, y+1 ), (x -1,y), (x,y-1)}

 N8 = {(x+1,y), (x, y+1 ), (x -1,y), (x,y-1), (x+1, y+1), (x-1,y-1), (x+1, y-1), (x-1, y+1)}

 

Summary
All results were as expected in the experiment. No human noticeable clock time was realized in performing the above operations.

 

D. Conclusions

Boolean operations can be performed on binary images of the same matrix dimensions. These operations are commonly used as masking functions. This allows for a subset of the image to be display or not displayed. Using complex Boolean expressions, one can create inverse patterns and other such detail features that may be effective for study.

The AND operation preserves any corresponding image pixel pair if both pixels are 1. This could be used for elementary image masking.

The XNOR operation preserves any corresponding image pixel pair if both pixels are the same value. This could be used to highlight similarities of a binary image.

The XOR operation preserves any corresponding image pixel pair if the pixels have different values. This could be used to highlight differences in a binary image.

The MAX function returns the maximum quantized gray level value for a corresponding pixel pair in two images. This can be used to blend images in a visually appealing way. Alternatively, this could also be used in scientific research to combine two data sets of relief data to study their combined effects. (eg. 2 plots of tissue density)

The IMSUBTRACT and IMABSDIFF functions operates on a corresponding image pixel pair returning their difference value. IMSUBTRACT differs from IMABSDIFF in that if the difference in a pixel pair is negative it 'grounds' the value to zero. IMABSDIFF will never return a negative value as it returns the absolute difference of a pixel pair. These functions are useful in motion tracking and video compression (MPEG).

Connected components are useful because they provide a mechanism to measure uniformities of pixel neighborhoods. They can be particularly useful in scientific application where the relationship among 2D data set is important. In the real-world, this could be used to determine lines or other curved and thin objects of an image as their neighboring pixels will have some intensity similarities.
 

   
E. Appendix

project1a.m source code.

project1b.m source code.