예제 #1
0
        public void Initialize(double[] data, int width, int height, IColorTable colorTable, IColorMap colorMap)
        {
            // set members
            _width   = width;
            _height  = height;
            _rawData = data;

            // set default for this
            _invalidPixelValueColor = Color.White;

            // allocate image buffer
            _data = new int[width * height];

            // set color table now, we need it during raw buffer creation
            // TODO: throw if null, initialize?
            _colorTable = colorTable;

            // create color map
            if (colorMap != null)
            {
                _colorMap = colorMap;
            }
            else
            {
                _colorMap = ColorMapFactory.Create(ColorMapTypes.Gray);
                _colorMap.Initialize();
                _colorMap.Bias     = 0.5;
                _colorMap.Contrast = 1;
            }

            // create raw image buffer.
            // separating this will  add more granularity saving time if we want to rebuild
            // since we dont want to recalc extremes again...etc
            CreateRawImageBuffer();
        }
예제 #2
0
        public void LoadColorMap(string file)
        {
            _modelState.ColorMap.Param = "";
            IColorMap cm = ColorMapFactory.FromFile(file);

            if (cm != null)
            {
                _modelState.ColorMap.Type = cm.Type;
                if (CurrentImage != null)
                {
                    CurrentImage.ColorMap = cm;
                    RaiseImageChanged();
                }
            }
        }
예제 #3
0
 public void SetColormapParams(ColorMapTypes colorMapType, string param)
 {
     if (_modelState.ColorMap.Type != colorMapType || _modelState.ColorMap.Param != param)
     {
         _modelState.ColorMap.Type  = colorMapType;
         _modelState.ColorMap.Param = param;
         IColorMap cm = ColorMapFactory.Create(colorMapType, param);
         if (cm != null)
         {
             cm.Initialize();
             if (CurrentImage != null)
             {
                 CurrentImage.ColorMap = cm;
                 RaiseImageChanged();
             }
         }
     }
 }
예제 #4
0
        static public IImage FromFile(string nicFile)
        {
            IImage       ii  = null;
            StreamReader sr  = null;
            XmlReader    r   = null;
            ImageTypes   it  = ImageTypes.Indexed;
            Color        nan = Color.Empty;

            try
            {
                sr = new StreamReader(nicFile);
                r  = XmlReader.Create(sr.BaseStream);
                r.ReadToFollowing("ImageConfig");
                it             = (ImageTypes)Enum.Parse(typeof(ImageTypes), r["Type"]);
                nan            = Color.FromArgb(int.Parse(r["NaNColor"]));
                r.Close(); r   = null;
                sr.Close(); sr = null;
                IColorTable ct = ColorTableFactory.FromFile(nicFile);
                IColorMap   cm = ColorMapFactory.FromFile(nicFile);
                ii = ImageFactory.Create(it);
                if (ii != null)
                {
                    ii.ColorTable             = ct;
                    ii.ColorMap               = cm;
                    ii.InvalidPixelValueColor = nan;
                }
            }
            finally
            {
                if (r != null)
                {
                    r.Close();
                }
                if (sr != null)
                {
                    sr.Close();
                }
            }

            return(ii);
        }
예제 #5
0
 public void SetUp()
 {
     _factory = new ColorMapFactory();
 }