public double iterate(NearestPointImg groupA, NearestPointImg groupB) {
		
		
		double distance = 0d;
		int width = groupA.getWidth();
		int height = groupA.getHeight();
		int nbWhitePoint = 0;
		
		if (debug) {
			debugImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		}
		
		
		for (int i = 0; i < width; i++) {
			for (int j = 0; j < height; j++) {
				if (groupA.getNearestDistanceFrom(i, j)==0) {
					nbWhitePoint++;
					double localDistance = calculateNeareastPointDistance(groupB,i,j); 
					distance += localDistance;
					
					
					//debug img
					if (debug) {
						int greyLevel = 255-((int) localDistance*20);
						if (greyLevel < 0) {
							greyLevel = 0;
						}
						debugImg.setRGB(i, j, ImgUtil.toRGB(greyLevel, greyLevel, greyLevel));	
					}
					
				} 
			}
		}

		/*System.out.println("DEBUG info");
		System.out.println("nbPoint: "+nbWhitePoint );
		System.out.println("distance: "+distance);*/
		return (distance/(double)nbWhitePoint);
	}