Archive for June, 2013

Image registration with genetic algorithms, again

06/28/2013

Given two images, we want to “reigster” them.

After resizing (pyramid, to speed-up the algorithm) and normalizing (to improve the registration) I’ve tried to find shift + rotation (3 degrees of freedom) using algorithms in matlab’s global optimization toolbox.

  • genetic-algorithm – results are good only if initial guess is good/ image offset is small, even with customized parameters.
  • Direct Search – very good results (but the offset is integer, for some reason)
  • Simulated Annealing – poor results

In all cases, the following function was used:

%try to make B similar to A
function a = cor(alfa1)
 global A B 
 global roi

 b1=imChange(B, alfa1);
 a1=imcrop(A, roi);
 a = 1-corr2(a1,b1);
end

%vector of form [offset-x, offset-y, angle]
function out = imChange(im, vector)
 global roi
 alfa = vector(3);
 offset = vector(1:2);
 B1=imrotate(im, alfa,'bicubic', 'crop');
 out=imcrop(B1, roi+[offset 0 0]);
end

Advertisements

Playing with Matlab

06/21/2013

Image registration using ga (genetic algorithm)

Given two images, A and B, try to find affine transformation to maximize correlation between the to images.

This simple code works on simple images with simple transformations.

function res=reg1()
 clear all;
 close all;

 global A B
 A=imread('/home/komap/Desktop/SuperResolutionMatlab/Data/IMAG0446.jpg');
 B=imread('/home/komap/Desktop/SuperResolutionMatlab/Data/IMAG0447.jpg');

 A=rgb2gray(A);
 B=rgb2gray(B)

 options = gaoptimset('Generations',50);
 options = gaoptimset(options,'MutationFcn',@mutationadaptfeasible);
 options = gaoptimset(options,'PlotFcns',{@gaplotbestf,@gaplotmaxconstr}, 'Display','iter');
 options = gaoptimset(options,'InitialPopulation',[1 0 0 0 1 0]);
 [a,fval] = ga(ObjectiveFunction,6, options);
end;

function a = cor(alfa)
 global A B
 alfa = reshape(alfa, 3, 2);
 t_n = maketform('affine', alfa);
 D = imtransform(A,t_n);
 D = imresize(D, size(B));

 a = 1-corr2(B, D);
end

Expirementing

06/21/2013

“Missing articles project” most popular articles from English Wikipedia that are missing in Russian Wikipedia – for approbation before I create those articles in WIkipedia, or just for fun.

http://missinginfo.blog.com

–update 28/6:
1 week later,

  • Дерехо” is 6 place in anonymous google search.
  • Аашикуиis the only 1 result
  • Малани Медиссон
  • – page, not a blog post – is not reachede by google.