Exemplo n.º 1
0
 //hokep kiolvasa a fajlbol
 public void readInfraredImage()
 {
     //irb fajl nevenek kiszedese
     try
     {
         fileName      = Path.GetFileName(filePath.Text).Split('.')[0];
         fileExtension = Path.GetFileName(filePath.Text).Split('.')[1];
         reader        = new Image_Fusion_Application.IrbFileReader(filePath.Text, fileExtension, "infrared");
         imgStream     = new Image_Fusion_Application.IrbImg(reader, "infrared");
         //hoertekek alapjan a hokeprol az objektum kiszedese
         getMask(imgStream.EnvironmentalTemp, imgStream.tempMatrix, imgStream.GetWidth(), imgStream.GetHeight());
         ShowNextFrame();
         var value     = thresholdScroll.Value / 100.0;
         var textValue = Math.Round((temperatures[0] + ((temperatures[1] - temperatures[0]) * value)) - 273, 1);
         thresholdText.Text = textValue.ToString();
     }
     catch (Exception e) {
         MessageBox.Show("Error while reading thermal image!\n" + e.Message);
     }
 }
Exemplo n.º 2
0
        private void ShowNextFrame()
        {
            var img      = imgStream.GetData();
            var w        = imgStream.GetWidth();
            var h        = imgStream.GetHeight();
            var dataSize = w * h;

            var maxValue = float.MinValue;
            var minValue = float.MaxValue;

            for (int i = 0; i < dataSize; i++)
            {
                maxValue = Math.Max(maxValue, img[i]);
                minValue = Math.Min(minValue, img[i]);
            }

            if (maxValue == minValue)
            {
                maxValue = minValue + 1;
            }

            DirectBitmap bmp = new DirectBitmap(w, h);

            float scale = 255.0f / (maxValue - minValue);

            //szinezes alapjan a hokep kirajzolasa
            switch (thermalType.Text)
            {
            case "Rainbow":
                for (int i = 0; i < dataSize; i++)
                {
                    var x = i % w;
                    var y = i / w;
                    var c = (int)((img[i] - minValue) * scale);
                    bmp.SetPixel(x, y, MapRainbowColor(img[i], minValue, maxValue));
                }
                break;

            case "Grayscale":
                for (int i = 0; i < dataSize; i++)
                {
                    var x = i % w;
                    var y = i / w;
                    var c = (int)((img[i] - minValue) * scale);
                    bmp.SetPixel(x, y, Color.FromArgb(c, c, c));
                }
                break;

            case "BlueToRed":
                for (int i = 0; i < dataSize; i++)
                {
                    var x = i % w;
                    var y = i / w;
                    var c = (int)((img[i] - minValue) * scale);
                    bmp.SetPixel(x, y, MapBlueToRedColor(img[i], minValue, maxValue));
                }
                break;

            case "Fire":
                for (int i = 0; i < dataSize; i++)
                {
                    var x = i % w;
                    var y = i / w;
                    var c = (int)((img[i] - minValue) * scale);
                    bmp.SetPixel(x, y, MapFireColor(img[i], minValue, maxValue));
                }
                break;

            default:
                for (int i = 0; i < dataSize; i++)
                {
                    var x = i % w;
                    var y = i / w;
                    var c = (int)((img[i] - minValue) * scale);
                    bmp.SetPixel(x, y, MapSevenRainbowColor(img[i], minValue, maxValue));
                }
                break;
            }
            ThermalImage.Image = bmp.Bitmap;
        }