コード例 #1
0
        private static void startImageProcessing(Bitmap A, Bitmap B, string outputfolder)
        {
            ImageProcessor imageProcessor = new ImageProcessor();
            Exporter exporter = new Exporter();
            RegistrationProcessor registrationProcessor = new RegistrationProcessor();

            //Create binary image of A with otsu threshold and save
            Bitmap image1bin = imageProcessor.createBinaryOtsu(A);
            image1bin.Save(outputfolder + "\\Abin.png", ImageFormat.Png);

            //Create binary image of B with otsu threshold and save
            Bitmap image2bin = imageProcessor.createBinaryOtsu(B);
            image2bin.Save(outputfolder + "\\Bbin.png", ImageFormat.Png);

            //Find contour of A - Only longest!
            List<Contour<Point>> contours_image1 = imageProcessor.findContoursWithOpenCV(image1bin);
            exporter.exportToCSV(contours_image1, outputfolder, "contourA.csv");
            Bitmap contour_image1 = exporter.exportToImage(contours_image1, outputfolder, "contourA.png", A.Height, A.Width);

            //Find contour of B - Only longest!
            List<Contour<Point>> contours_image2 = imageProcessor.findContoursWithOpenCV(image2bin);
            exporter.exportToCSV(contours_image2, outputfolder, "contourB.csv");
            Bitmap contour_image2 = exporter.exportToImage(contours_image2, outputfolder, "contourB.png", B.Height, B.Width);

            //Calculate transformation with help of the two contours
            try
            {
                Transformation t1 = registrationProcessor.calculateTransformation(contours_image1, contours_image2);
                //Start registration of contours
                Bitmap registrated_Contours = registrationProcessor.registrationContour(t1, contour_image1, contour_image2);
                registrated_Contours.Save(outputfolder + "\\contoursR.png", ImageFormat.Png);

                //Start registration of orginial images
                Bitmap registrated_originals = registrationProcessor.registrationBitmap(t1, A, B);
                registrated_originals.Save(outputfolder + "\\registration.png", ImageFormat.Png);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }