Beispiel #1
0
        /// <summary>
        /// async method to compare
        /// </summary>
        /// <param name="secImg"></param>
        /// <returns></returns>
        public async Task <Int16Image> CompareImagesAsync(Int16Image secImg)
        {
            if (!IsSameDimension(secImg))
            {
                throw new ArgumentOutOfRangeException("Images must be the same width and height!");
            }
            var newImage = new Int16Image("comparison of" + _fileName + " " + secImg.GetFileName(), _width, _height);

            List <Task> imgTasks = new List <Task>();

            for (var h = 0; h < _height; h++)
            {
                int row = h;
                imgTasks.Add(Task.Run(() => newImage.CompareRow(row, this, secImg)));
            }

            while (imgTasks.Any())
            {
                Task finished = await Task.WhenAny(imgTasks);

                Console.WriteLine("Row complete");
                imgTasks.Remove(finished);
            }

            return(newImage);
        }
Beispiel #2
0
        private void CompareRow(int row, Int16Image firstImg, Int16Image secImg)
        {
            var firstImgRow = firstImg.GetRow(row);
            var secImgRow   = secImg.GetRow(row);

            for (int w = 0; w < _width; w++)
            {
                _fileArr[row][w] = (UInt16)(firstImgRow[w] - secImgRow[w]);
            }
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            //Int16Image image1 = new Int16Image("sino800_540x1200.RAW", 1200, 500);
            //Int16Image image2 = new Int16Image("sino801_540x1200.RAW", 1200, 500);
            //var image3 = image1.CompareImages(image2);
            //image3.OutPutTofile();
            var image1 = new Int16Image("sino800_540x1200.RAW", 1200, 540);
            var image2 = new Int16Image("sino801_540x1200.RAW", 1200, 540);

            image1.LoadUint16File("sino800_540x1200.RAW", 1200, 540);
            image2.LoadUint16File("sino801_540x1200.RAW", 1200, 540);
            var image3 = image1.CompareImagesAsync(image2).GetAwaiter().GetResult();

            image3.OutputToFile();
        }
Beispiel #4
0
        /// <summary>
        /// non async method of compare images
        /// </summary>
        /// <param name="secImg"></param>
        /// <returns></returns>
        public Int16Image CompareImages(Int16Image secImg)
        {
            if (!IsSameDimension(secImg))
            {
                throw new ArgumentOutOfRangeException("Images must be the same width and height!");
            }
            var newImage = new Int16Image("comparison of" + _fileName + " " + secImg.GetFileName(), _width, _height);

            List <Task> imgTasks = new List <Task>();

            for (var h = 0; h < _height; h++)
            {
                int row = h;
                newImage.CompareRow(row, this, secImg);
            }

            return(newImage);
        }
Beispiel #5
0
 public bool IsSameDimension(Int16Image otherImg)
 {
     return(_width == otherImg._width && _height == otherImg._height);
 }