Course: Computer Vision
Student Name: Moustafa Magdy Ahmed Othman Abu-Ghazy
Section: 4
4th Computer Engineering Branch
Electronics, Communication and Computer Department
Faculty of Engineering at Helwan, Helwan University
Constant Area Coding (CAC) is a Lossless Compression Algorithm that allows the reconstruction of the exact original from the compressed data****reduces a file's size with no loss of quality.
Other Lossless Compression Technique Algorithms:
- Run length encoding
- Huffman encoding
- Lempel–Ziv–Welch (LZW) coding
- Special codeword's are used to identify large areas of contiguous 1's or 0's
- The whole image (M*N Pixels) is divided into blocks of size (P*Q Pixels)
- Blocks are classified as
- White (W) Blocks: having only white pixels
- Black (B) Blocks: having only black pixels
- Mixed (M) Blocks: having mixed intensity.
- The most frequent occurring category is assigned with 1-bit codeword 0
- If image contain only two categories, the other category is assigned with 1-bit codeword 1
- Else the remaining other two categories are assigned with 2-bit codes 10 and 11
- The codeword assigned to the Mixed (M) Block category is used as a prefix, which is followed by the P*Q-bit pattern of the block.
- Compression is achieved because the P*Q bits that are normally used to represent each constant area (block) are replaced by a 1-bit or 2-bit codeword for White and Black Blocks
- Compression Ratio (CR) = (N1 / N2)
Where:
- N1 = M*N * (Pixel Size)
Where: Pixel Size = 1-bit for 1-bit monochrome image
Pixel Size = 8-bit for 8-bit monochrome binary image
- N2 = (#no of W-Blocks) * (Length of W-Block codeword)
+ (#no of B-Blocks) * (Length of B-Block codeword)
+ (#no of M-Blocks) * [(Length of B-Block codeword)
+ P*Q*(1-bit)]
- Relative Data Redundancy (RD) = 1 – (1 / CR)
- Root Mean Square Error (Er.m.s) = 0
- Mean Square Signal to Noise Ratio (SNRMS) = ∞
The Compression Ratio (CR) and Relative Data Redundancy (RD) depend on two main factors:
- Nature of Image itself
- Values of chosen block size (P*Q)
To get the optimized values for block size (P*Q) that achieve max Compression Ratio (CR) for a specific image we have to use one of the two ways:
- Use Brute Force to test all possible sizes (P*Q)
- Use AI like Genetic Algorithm (GA) to minimize the search space and reach faster to an approximated solution
The Constant Area Coding (CAC) Algorithm can also use for normal 8-bit monochrome image using concept of 1-bit plane, dividing the image into 8 1-bit planes then compress each plane individual and collect results together.
Also, it used to compress any stream of bits not only images.
Genetic Algorithm (GA) is adaptive heuristic search algorithm based on the evolutionary ideas of natural selection and genetics. As such they represent an intelligent exploitation of a random search used to solve optimization problems. Although randomized, GA is by no means random, instead they exploit historical information to direct the search into the region of better performance within the search space.
It is better than conventional AI in that it is more robust. Unlike older AI systems, they do not break easily even if the inputs changed slightly, or in the presence of reasonable noise.
GAs simulate the survival of the fittest among individuals over consecutive generation for solving a problem. Each generation consists of a population of character strings that are analogous to the chromosome that we see in our DNA. Each individual represents a point in a search space and a possible solution. The individuals in the population are then made to go through a process of evolution.
-
Randomly initialize Populations
-
Evolution: Determine fitness of Population and ranking them
-
Repeat:
-
Select Mating Pools (Parents) from Populations
-
Perform crossover on Mating Pools resulting Offsprings
-
Perform mutation on Offsprings resulting Mutants
-
Set Mutants as the next generation Populations
-
Evolution: Determine fitness of Population and ranking them
-
Until Exit Condition
May be:
- Reach maximum number of generations
- Reach to a solution is good enough (Δ Error Convergence)
May add restriction on minimum number of generations to be executed
Effects of Genetic Operators:
- Using selection alone will tend to fill the population with copies of the best individual from the population
- Using selection and crossover operators will tend to cause the algorithms to converge on a good but sub-optimal solution
- Using mutation alone induces a random walk through the search space.
- Using selection and mutation creates a parallel, noise-tolerant, hill climbing algorithm
- Minimum Number of Generations
- Δ Error for Convergence
- Population Size
- Number of Mating Pools
- Mutation Percentage
-
Chromosome consist of two Genes
- 1st Gene: Block Width
- 2nd Gene: Block Height
-
Fitness Function: CAC returns Compression Ratio (CR)
-
Minimum Number of Generations = 5
-
Δ Error for Convergence = 0.00001
-
Population Size:
- Random generated in range of (3, 10% of #no of Possible Solutions)
- = 3 if (#no of Possible Solutions < 30)
-
Number of Mating Pools:
- Random generated in range of (2, Population Size)
- = Population Size if (Population Size < 2)
-
Mutation Percentage {0%,50%,100%}: 50%
- Dataset Size: 1407 Binary Image
(Dealt with them as 1-bit images)
- Brute Force Trials per Image: 1
- Brute Force Trials per Image: 10
- Total Number of Records: 15565
Genetic Algorithm
- It's noticed the values of Average Genetic Algorithm _ Max CR are mostly near to the _ values of Brute Force _ Max CR _
- It's noticed the _ Execution Time _ for Brute Force of Genetic Algorithm increasing with nonlinear behavior by the increase of the _ Number of Possible Sizes _
- Average _ Execution Time _ of Genetic Algorithm is more less than _ Execution Time _ for Brute Force
- It's notices the Generation Counter of Genetic Algorithm mostly hit 5 Generation. So, it's a reason for changing the _ Minimum Number of Generations _ to value less than 5 like to be 3