Probability is a way of expressing knowledge or belief that an event will occur or has occurred. The probability of the occurrence of an event A is written as P(A). A probability is assigned a value between 0-1.
Conditional probability, denoted P(A|B), which is read “the probability of event A, given event B”, is the probability of event A occurs, given the occurrence of some other event B.
Baye’s Rule. Baye’s rule states that
P(A|B) = P(B|A) * P(A) / P(B)
That is, the probability of event A occurs given event B occurs P(A|B) can be computed using
1. the probability of event B occurs given event A occurs P(B|A),
2. the probability of event A occurs P(A), and
3. the probability of event B occurs P(B).
Digital images are stored in computer as a collection of its pixel values (as well as other information). Each pixel value is an integer that incorporates its R, G and B value for this pixel. Each R,G or B value is in the range of 0~255. Different combinations of R, G and B values produce different colors.
A C program will be created that builds a database for different colors from input images. The images represent environments where both safe and unsafe regions exist. The database then is used to retrieve information about the probability of a given color representing the safe or unsafe regions of the environment.
The program scans through an input file which contains a set of pixels values of some sample images and generate a database for different colors of the images.
The images have different sizes, and each image consists of a safe region surrounded by two unsafe regions, as shown below where shaded areas in the images are safe regions and white areas are unsafe regions. (A safe region can represent, for example, a bridge, and unsafe regions are rivers, or, a safe region represents a path where no landmines are placed and unsafe regions are full of landmines.)
After reading and processing all the input pixel values, the program is able to answer, for a particular color, what is the probability that the color belongs to a safe region. That is, the probability that the color represents the safe region. Denoted as P(safe-region | color) and based on Bayes’ rule, this probability can be computed as:
P(safe-region | color) = P(color | safe-region) * P(safe-region) / P(color)
where,
|
is the probability that color color is observed, given that the safe region is observed, |
|
is the probability of the observing the safe region, and |
|
is the probability of the observing color color. |
Among the input pixels, some pixels represent a safe region, and some are not. Each pixel is of a particular color. Given this,
|
is the probability of the observing the safe region, can be computed as the ratio of the total number of ‘safe pixel’ observed over the total number of pixels scanned. |
|
is the probability of observing color color, can be computed as the ratio of number of color pixel that are observed (no matter it is a safe pixel or not) over the total number of pixels scanned. |
|
is the probability that the color is observed, given a ‘safe pixel’ is observed, can be computed as the ratio of the number of color pixels which are ‘safe pixel’ over the number of all the safe pixels scanned. |