Your program tends to get very high value as you summed all pixels' Euclidean distance together:
euclidean=(euclidean+sqrt(pow(b2-b,2) + pow(g2-g, 2) + pow(r2-r,2)));
I suggest you to do as follows:
Compute color histogram (vector features) of the images.
Compute correlation coefficient between these histograms as the differences of the images.