Mil学习之 多相机图像均一性校正

Posted Thomas会写字

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mil学习之 多相机图像均一性校正相关的知识,希望对你有一定的参考价值。

        适用于多个相机的场景,此时多个相机拍图的均一性是有一定差异的,我们可以使用Mil的模块进行一定的补偿校正。

        Mim模块的M_FLAT_FIELD_CONTEXT属性。

需要校正相机的暗图

需要校正相机的暗图

需要校正相机的亮图 

需要校正相机的亮图

标准相机的暗图 

需要校正的输入图片 

需要校正的输出图片

// This code was generated by MIL CoPilot 10.40.881
// on Thursday, June 24, 2021
// Compiling and running generated code will require :
// MIL 10 with Service Pack 4

using System;
using System.Text;
using Matrox.MatroxImagingLibrary;

namespace MilCoPilot_Untitled
   {
   class Program
      {
      private const string IMAGE_FILE = @"C:\\Users\\kakie\\Desktop\\black.bmp";
      private const string IMAGE1_FILE = @"C:\\Users\\kakie\\Desktop\\white.bmp";
      private const string IMAGE2_FILE = @"C:\\Users\\kakie\\Desktop\\okBlack.bmp";

      static void Main(string[] args)
         {
         MIL_ID MilApplication = MIL.M_NULL;
         MIL_ID MilSystem = MIL.M_NULL;
         MIL_ID ProcessingContext = MIL.M_NULL;
         MIL_ID black = MIL.M_NULL;
         MIL_ID white = MIL.M_NULL;
         MIL_ID okBlack = MIL.M_NULL;
         MIL_ID ImageTest = MIL.M_NULL;
         MIL_ID MimFlatFielddestination = MIL.M_NULL;

         MIL.MappAlloc(MIL.M_NULL, MIL.M_DEFAULT, ref MilApplication);
         MIL.MsysAlloc(MIL.M_DEFAULT, "M_SYSTEM_HOST", MIL.M_DEFAULT, MIL.M_DEFAULT, ref MilSystem);
         MIL.MbufImport(IMAGE_FILE, MIL.M_DEFAULT, MIL.M_RESTORE + MIL.M_NO_GRAB + MIL.M_NO_COMPRESS, MilSystem, ref black);
         MIL.MbufImport(IMAGE1_FILE, MIL.M_DEFAULT, MIL.M_RESTORE + MIL.M_NO_GRAB + MIL.M_NO_COMPRESS, MilSystem, ref white);
         MIL.MbufImport(IMAGE2_FILE, MIL.M_DEFAULT, MIL.M_RESTORE + MIL.M_NO_GRAB + MIL.M_NO_COMPRESS, MilSystem, ref okBlack);

         MIL.MbufRestore(@"C:\\Users\\kakie\\Desktop\\test.bmp", MilSystem, ref ImageTest);
         MIL.MbufClone(ImageTest, MIL.M_DEFAULT, MIL.M_DEFAULT, MIL.M_DEFAULT, MIL.M_DEFAULT, MIL.M_DEFAULT, MIL.M_DEFAULT, ref MimFlatFielddestination);
         MIL.MimAlloc(MilSystem, MIL.M_FLAT_FIELD_CONTEXT, MIL.M_DEFAULT, ref ProcessingContext);

         // Control Block for Processing Context
         MIL.MimControl(ProcessingContext, MIL.M_DARK_IMAGE, black);
         MIL.MimControl(ProcessingContext, MIL.M_FLAT_IMAGE, white);
         MIL.MimControl(ProcessingContext, MIL.M_OFFSET_IMAGE, okBlack);
         MIL.MimControl(ProcessingContext, MIL.M_GAIN_CONST, 255.0);

         MIL.MimFlatField(ProcessingContext, MIL.M_NULL, MIL.M_NULL, MIL.M_PREPROCESS);
         MIL.MimFlatField(ProcessingContext, ImageTest, MimFlatFielddestination, MIL.M_DEFAULT);

         Console.WriteLine("Press <ENTER> to continue");
         Console.ReadKey();

         MIL.MbufFree(MimFlatFielddestination);
         MIL.MbufFree(ImageTest);
         MIL.MimFree(ProcessingContext);
         MIL.MbufFree(okBlack);
         MIL.MbufFree(white);
         MIL.MbufFree(black);
         MIL.MsysFree(MilSystem);
         MIL.MappFree(MilApplication);
         }
      }
   }

以上是关于Mil学习之 多相机图像均一性校正的主要内容,如果未能解决你的问题,请参考以下文章

Mil学习之Mdisp

Mil学习之Mbuf

Mil学习之Mcal

Mil学习之Mim的简单操作

Mil学习之显示鼠标交互交互绘图交互Mask

Mil学习之Mim的简单操作