I'm trying to optimize an image reconstruction algorithm using genetic algorithm.I took initial population size as 10.I have an input image an 10 reconstructed image.fitness function is the difference between these two.That is

fitness_1 = inputimage - reconstructedimage_1;
fitness_2 = inputimage - reconstructedimage_2;
fitness_10 = inputimage - reconstructedimage_10;

I want to chose the best fitness population among them.But my fitness result is an image(matrix with intensity values).So how can I get a single fitness value for each population for doing crossover in the next stage. Please help.Thanks in advance

  • 1
    $\begingroup$ Well, what's a good reconstructed image ? Do you have any measurable way to tell that one image is better reconstructed than an other ? $\endgroup$
    – Loufylouf
    Mar 31, 2015 at 9:24

1 Answer 1


One simple approach would be taking the mean square error (MSE) by using

fitness_1 = mean((inputimage(:) - reconstructedimage_1(:)).^2)

though, as your image size won't change, you can ommit the mean and use sum instead.

fitness_1 = sum((inputimage(:) - reconstructedimage_1(:)).^2)

In general you want to have some kind of distance measure. Look at Wikipedia (especially at Other distances) for more sophisticated approaches.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.