AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

registration of images with different focus

The forum is to discuss topics related to different areas of image processing and computer vision.

registration of images with different focus

Postby guy30020 » Wed May 07, 2014 3:23 pm

I'm trying to fuse different images of the same scene which each image have a different focus. I've been told that first I have to perform an image registration to the images.
Right now, the result from the registration has errors, which can be seen by "aura" around the objects in the images and shrinking the image edges.

When I'm trying to register images with focuses that their distance is big, I'm getting a result images with much more significant errors.

I'm using the following code (using the AForge & Accord libraries):

class Registration
{
private List<Image<Bgr, Byte>> myOriginalImages;
private List<Bitmap> registratedImages = new List<Bitmap>();

public Registration(List<Image<Bgr, Byte>> myOriginalImages)
{
this.myOriginalImages = myOriginalImages;
}

public List<Bitmap> getRegistratedImages()
{
return registratedImages;
}
public void Run()
{
int numOfTargetImages = myOriginalImages.Count - 1;
SpeededUpRobustFeaturePoint[] surfPoints1;
SpeededUpRobustFeaturePoint[] surfPoints2;
IntPoint[] correlationPoints1;
IntPoint[] correlationPoints2;
MatrixH homography;
Bitmap registratedImage;

// first image is the model image - no registration required
registratedImages.Add(myOriginalImages.ElementAt(0).ToBitmap());
Bitmap modelImage = registratedImages.ElementAt(0);

// create the registrated images
for (int i = 1; i <= numOfTargetImages; i++)
{
ExtractFeatures(modelImage, myOriginalImages.ElementAt(i).ToBitmap(), out surfPoints1, out surfPoints2);
MatchFeatures(surfPoints1, surfPoints2, out correlationPoints1, out correlationPoints2);
homography = RANSAC(correlationPoints1, correlationPoints2);
registratedImage = CreateRegisteredImage(modelImage, myOriginalImages.ElementAt(i).ToBitmap(), homography);

registratedImages.Add(registratedImage);
}
}
private void ExtractFeatures(Bitmap img1, Bitmap img2, out SpeededUpRobustFeaturePoint[] surfPoints1, out SpeededUpRobustFeaturePoint[] surfPoints2)
{// extract features using SURF detector
SpeededUpRobustFeaturesDetector surf = new SpeededUpRobustFeaturesDetector();

surfPoints1 = surf.ProcessImage(img1).ToArray();
surfPoints2 = surf.ProcessImage(img2).ToArray();
}

private void MatchFeatures(SpeededUpRobustFeaturePoint[] surfPoints1, SpeededUpRobustFeaturePoint[] surfPoints2, out IntPoint[] correlationPoints1, out IntPoint[] correlationPoints2)
{// match the features between the images by using correlation
KNearestNeighborMatching matcher = new KNearestNeighborMatching(5);
IntPoint[][] matches = matcher.Match(surfPoints1, surfPoints2);

correlationPoints1 = matches[0];
correlationPoints2 = matches[1];
}

private MatrixH RANSAC(IntPoint[] correlationPoints1, IntPoint[] correlationPoints2)
{
RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.001, 0.99);
MatrixH homography = ransac.Estimate(correlationPoints1, correlationPoints2);

return homography;
}

private Bitmap CreateRegisteredImage(Bitmap img1, Bitmap img2, MatrixH homography)
{
Blend blend = new Blend(homography, img1);
return blend.Apply(img2);
}

any idea how to improve the registration?
guy30020
 
Posts: 1
Joined: Wed May 07, 2014 3:17 pm



Return to Image Processing and Computer Vision