Scale Invariant Object Detection using a Hybrid Genetic Algorithm – Fuzzy Logic Approach Group – 9 Ayesha Farrukh [ ] Junaid Akhtar [ ]
Progress Matlab Implementation – Brute force Template Matching Initialize Population Crossover Mutation Fitness Function
Brute Force Results Reference Image Template (145, 171)
Cross Correlation Surface
Correlation Surface [zoomed in] Peak value at: (145, 171) Value =
Tic-Toc This operation took seconds
Other Matlab Functions Explored DEC2BIN BIN2DEC RAND CORR2
GA Pseudocode StartGA( img, template ) // Initialize a random population of individuals P = initPopulation ( populationSize, imgDimension, scaleDimension ); // Evaluate fitness of all initial individuals of population [fitnessP, fuzzyClassifictaionP ] = calcFitness ( P, img, template ); // test for termination criterion: (Correlation Value > THRESHOLD) WHILE not done do // select a sub-population for offspring production selectedP = selectparents( P ); // Crossover [newP] = crossover( selectedP ); // Mutate x OR y OR scale value randomly [mutatedP] = mutate( newP ); // Evaluate fitness of new calcFitness( mutatedP ); // select the survivors from actual fitness P = survive( P, mutatedP ); END
Chromosome Definition x = 49y = 252 Index of Scale to Use
512 x 512 Reference Image
Template Image
Scale imresize Bicubic Interpolation for resizing the template image
Initial Population function [initialPopulation, lengthImageDimension, lengthMaxScale] = initialize(populationSize, imageDimension, maxScale) binaryImageDimension = dec2bin(imageDimension); binaryMaxScale = dec2bin(maxScale); lengthImageDimension = length(binaryImageDimension); lengthMaxScale = length(binaryMaxScale); bitsInitialPopulation = (2 * lengthImageDimension) + lengthMaxScale; initialPopulation = zeros(populationSize, bitsInitialPopulation); for i = 1:populationSize xLocation = round(imageDimension*rand); xLocation = dec2bin(xLocation); initialPopulation(i,length(binaryImageDimension) - length(xLocation) + 1 :length(binaryImageDimension)) = xLocation - 48; yLocation = round(imageDimension*rand); yLocation = dec2bin(yLocation); initialPopulation(i,(2*length(binaryImageDimension)) - length(yLocation) + 1 :2*length(binaryImageDimension)) = yLocation - 48; scale = round(maxScale*rand); scale = dec2bin(scale); initialPopulation(i,bitsInitialPopulation - length(scale) + 1 : bitsInitialPopulation) = scale - 48; end
Select Parents Sort the current Population according to their respective fitness values Select the best
CalculateFitness Use corr2 function to calculate fitness for each individual Classify each individual using Fuzzy classifiers: Negative, Low, & Positive correlation
Crossover function [newPopulation] = crossover(selectedPopulation) sizeSelectedPopulation = size(selectedPopulation,1); sizeIndividual = size(selectedPopulation,2); count = 1; while count < sizeSelectedPopulation crossoverPoint = round(sizeIndividual*rand) newPopulation(count,:) = selectedPopulation(count,:); newPopulation(count+1,:) = selectedPopulation(count+1,:); newPopulation(count,crossoverPoint:sizeIndividual) = selectedPopulation(count+1,crossoverPoint:sizeIndividual); newPopulation(count+1,1:crossoverPoint-1) = selectedPopulation(count,1:crossoverPoint-1); count = count + 2; end
Mutate( P ) For each member of the selected population ‘P’ Randomly decide whether or not to mutate Randomly decide index of bit to mutate Perform mutation
Next Episode Integrate the components Compile Results on Different Images Use information generated during fuzzy classification to improve matching time Compare Tic-Toc Results for time Compare FLOPS for memory