Constructing an image from multiple line-scan images

Hi @roman5991,

the best way is to create a new image with the width dimension of the original images and the hight dimension equal to the number of images to stitch times the lines of the original image.

Here is quick example of stitching the same image 4 times to a new image:

Original image:
image

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Stemmer.Cvb;

namespace CVB_StitchImages
{
  internal class Program
  {
    static void Main(string[] args)
    {
      int imgCount = 4;
      Image[] imgs = new Image[imgCount];
      for(int i = 0 ; i < imgs.Length; i++)
      {
        imgs[i] = Image.FromFile("img.tif");
      }
      var height = imgs[0].Height;
      var heightStitch = height * imgCount;
      Image stitchedImage = new Image(imgs[0].Width, heightStitch, imgs[0].Planes.Count, imgs[0].Planes[0].DataType);

      LinearAccessData<UInt16> stitchedImage_LinAcc = stitchedImage.Planes[0].GetLinearAccess<UInt16>();
      for (int i = 0 ;i < imgs.Length; i++)
      {
        LinearAccessData<UInt16> linacc = imgs[i].Planes[0].GetLinearAccess<UInt16>();
        for(int j = 0 ; j < imgs[i].Width ; j++)
        {
          for(int k = 0; k < imgs[i].Height ; k++)
          {
            stitchedImage_LinAcc[j, k + (imgs[i].Height * i)] = linacc[j, k];
          }
        }        
      }
      stitchedImage.Save("StitchedImage.tif");
    }
  }
}

Stitched image:

3 Likes