Beispiel #1
0
        private static void ProcessFiles(IEnumerable <string> fileNames, int?width, int?height, float?scale)
        {
            var rescaler = new Rescaler();

            foreach (var fileName in fileNames)
            {
                var sb = new StringBuilder($"{fileName} - ");

                try
                {
                    var filePathArray = fileName.Split("\\");
                    var fileNameArray = filePathArray.Last().Split(".");
                    if (!int.TryParse(fileNameArray[0], out var _))
                    {
                        continue;
                    }

                    var result = rescaler.RescaleMap(fileName, width, height, scale);

                    sb.Append(!string.IsNullOrWhiteSpace(result.ErrorMessage)
                                                ? result.ErrorMessage
                                                : $"rescaled from [ {result.OldWidth},{result.OldHeight} ] to [ {result.NewWidth},{result.NewHeight} ] ");
                }
                catch (Exception ex)
                {
                    sb.Append(ex);
                }

                Console.WriteLine(sb.ToString());
            }
        }
Beispiel #2
0
    public static int Main(string[] args)
    {
        string      file1  = args[0];
        ImageReader reader = new ImageReader();

        reader.SetFileName(file1);
        bool ret = reader.Read();

        if (!ret)
        {
            return(1);
        }

        Image       image     = reader.GetImage();
        PixelFormat pixeltype = image.GetPixelFormat();

        Rescaler r = new Rescaler();

        r.SetIntercept(0);
        r.SetSlope(1.2);
        r.SetPixelFormat(pixeltype);
        PixelFormat outputpt = new PixelFormat(r.ComputeInterceptSlopePixelType());

        System.Console.WriteLine("pixeltype");
        System.Console.WriteLine(pixeltype.toString());
        System.Console.WriteLine("outputpt");
        System.Console.WriteLine(outputpt.toString());

        uint len = image.GetBufferLength();

        short[] input = new short[len / 2]; // sizeof(short) == 2
        image.GetArray(input);

        double[] output = new double[len / 2];
        r.Rescale(output, input, len);

        // First Pixel is:
        System.Console.WriteLine("Input:");
        System.Console.WriteLine(input[0]);

        System.Console.WriteLine("Output:");
        System.Console.WriteLine(output[0]);

        return(0);
    }
Beispiel #3
0
    public static int Main(string[] args)
    {
        string file1 = args[0];
        ImageReader reader = new ImageReader();
        reader.SetFileName( file1 );
        bool ret = reader.Read();
        if( !ret )
          {
          return 1;
          }

        Image image = reader.GetImage();
        PixelFormat pixeltype = image.GetPixelFormat();

        Rescaler r = new Rescaler();
        r.SetIntercept( 0 );
        r.SetSlope( 1.2 );
        r.SetPixelFormat( pixeltype );
        PixelFormat outputpt = new PixelFormat( r.ComputeInterceptSlopePixelType() );

        System.Console.WriteLine( "pixeltype" );
        System.Console.WriteLine( pixeltype.toString() );
        System.Console.WriteLine( "outputpt" );
        System.Console.WriteLine( outputpt.toString() );

        uint len = image.GetBufferLength();
        short[] input = new short[ len / 2 ]; // sizeof(short) == 2
        image.GetArray( input );

        double[] output = new double[ len / 2 ];
        r.Rescale( output, input, len );

        // First Pixel is:
        System.Console.WriteLine( "Input:" );
        System.Console.WriteLine( input[0] );

        System.Console.WriteLine( "Output:" );
        System.Console.WriteLine( output[0] );

        return 0;
    }