Example #1
0
        private IColorMap ProcessFilters(RawMap<ushort> map, IIAutoAdjustableFilter autoFilter = null)
        {
            var indColorFilter = new List<IndependentComponentColorToColorFilter<float, float>>();
            var indVectorFilter = new List<IndependentComponentVectorToVectorFilter>();
            IColorMap currentMap = map;
            foreach (var filter in _filters)
            {
            #if DEBUG
                if (currentMap is ColorMapFloat)
                {
                    var m = currentMap as ColorMapFloat;
                    if (m.Rgb.Any(float.IsNaN)) throw new Exception();
                }
            #endif
                if (filter == null)
                    throw new ArgumentNullException("filter");

                if (filter == autoFilter)
                {
                    if (filter is IAutoAdjustableFilter<ColorMapFloat>)
                    {
                        if (currentMap is ColorMapUshort)
                        {
                            currentMap = ApplyIndependentColorToFloatFilters((ColorMapUshort)currentMap,
                                indColorFilter);
                        }
                        ((IAutoAdjustableFilter<ColorMapFloat>)autoFilter).AutoAdjust((ColorMapFloat)currentMap);
                    }
                    else  if (filter is IAutoAdjustableFilter<VectorMap>)
                    {
                        if (currentMap is ColorMapUshort)
                        {
                            currentMap = ApplyIndependentColorToVectorFilters((ColorMapUshort)currentMap,
                                indVectorFilter);
                        }
                        ((IAutoAdjustableFilter<VectorMap>)autoFilter).AutoAdjust((VectorMap)currentMap);
                    }
                    else
                        throw new NotSupportedException("Not supported AutoAdjust Filter: " + filter.GetType() +
                                                        " for Map: " + currentMap.GetType());
                    return currentMap;
                }

                if (currentMap is RawBGGRMap<ushort>)
                {
                    if (filter is IRawToColorMap16Filter<RawBGGRMap<ushort>, ushort>)
                    {
                        currentMap = ApplyRawBGGRToColorMapFilter((RawBGGRMap<ushort>)currentMap,
                            (IRawToColorMap16Filter<RawBGGRMap<ushort>, ushort>)filter);
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported Filter: " + filter.GetType() + " for Map: " +
                                                        currentMap.GetType());
                    }
                }
                else if (currentMap is ColorMapUshort)
                {
                    if (filter is IndependentComponentColorToColorFilter<float, float>)
                    {
                        indColorFilter.Add((IndependentComponentColorToColorFilter<float, float>)filter);
                    }
                    else if (filter is IndependentComponentVectorToVectorFilter)
                    {
                        indVectorFilter.Add((IndependentComponentVectorToVectorFilter)filter);
                    }
                    else if (filter is ColorToColorFilter<float, byte>)
                    {
                        currentMap = ApplyIndependentColorFiltersWithRGB((ColorMapUshort)currentMap,
                            indColorFilter, (IndependentComponentColorToColorFilter<float, byte>)filter);
                    }
                    else if (filter is ColorToColorFilter<float, float>)
                    {
                        currentMap = ApplyIndependentColorToFloatFilters((ColorMapUshort)currentMap,
                            indColorFilter);
                        ApplySingleFilterInplace((ColorMap<float>)currentMap, (ColorToColorFilter<float, float>)filter);
                    }
                    else if (filter is VectorToColorFilter<byte>)
                    {
                        currentMap = ApplyIndependentVectorFiltersWithRGB((ColorMapUshort)currentMap,
                            indVectorFilter, (IndependentComponentVectorToColorFilter<byte>)filter);
                    }
                    else if (filter is VectorToVectorFilter)
                    {
                        currentMap = ApplyIndependentColorToVectorFilters((ColorMapUshort)currentMap,
                            indVectorFilter);
                        ApplySingleFilterInplace((VectorMap)currentMap, (VectorToVectorFilter)filter);
                    }
                    else
                        throw new NotSupportedException("Not supported Filter: " + filter.GetType() + " for Map: " +
                                                        currentMap.GetType());
                }
                else if (currentMap is ColorMapFloat)
                {
                    if (filter is ColorToColorFilter<float, float>)
                    {
                        ApplySingleFilterInplace((ColorMapFloat)currentMap, (ColorToColorFilter<float, float>)filter);
                    }
                    else if (filter is ColorToColorFilter<float, byte>)
                    {
                        currentMap = ConvertToRGB((ColorMapFloat)currentMap, (ColorToColorFilter<float, byte>)filter);
                    }
                    else
                        throw new NotSupportedException("Not supported Filter: " + filter.GetType() + " for Map: " +
                                                        currentMap.GetType());
                }
                else if (currentMap is VectorMap)
                {
                    if (filter is VectorToVectorFilter)
                    {
                        ApplySingleFilterInplace((VectorMap)currentMap, (VectorToVectorFilter)filter);
                    }
                    else if (filter is VectorToColorFilter<byte>)
                    {
                        currentMap = ConvertToRGB((VectorMap)currentMap, (VectorToColorFilter<byte>)filter);
                    }
                    else
                        throw new NotSupportedException("Not supported Filter: " + filter.GetType() + " for Map: " +
                                                        currentMap.GetType());
                }
                else
                {
                    throw new NotSupportedException("Not supported Map: " + currentMap.GetType());
                }
            }
            return currentMap;
        }
Example #2
0
        private IColorMap ProcessFilters(RawMap <ushort> map, IIAutoAdjustableFilter autoFilter = null)
        {
            var       indColorFilter  = new List <IndependentComponentColorToColorFilter <float, float> >();
            var       indVectorFilter = new List <IndependentComponentVectorToVectorFilter>();
            IColorMap currentMap      = map;

            foreach (var filter in _filters)
            {
#if DEBUG
                if (currentMap is ColorMapFloat)
                {
                    var m = currentMap as ColorMapFloat;
                    if (m.Rgb.Any(float.IsNaN))
                    {
                        throw new Exception();
                    }
                }
#endif
                if (filter == null)
                {
                    throw new ArgumentNullException("filter");
                }

                if (filter == autoFilter)
                {
                    if (filter is IAutoAdjustableFilter <ColorMapFloat> )
                    {
                        if (currentMap is ColorMapUshort)
                        {
                            currentMap = ApplyIndependentColorToFloatFilters((ColorMapUshort)currentMap,
                                                                             indColorFilter);
                        }
                        ((IAutoAdjustableFilter <ColorMapFloat>)autoFilter).AutoAdjust((ColorMapFloat)currentMap);
                    }
                    else if (filter is IAutoAdjustableFilter <VectorMap> )
                    {
                        if (currentMap is ColorMapUshort)
                        {
                            currentMap = ApplyIndependentColorToVectorFilters((ColorMapUshort)currentMap,
                                                                              indVectorFilter);
                        }
                        ((IAutoAdjustableFilter <VectorMap>)autoFilter).AutoAdjust((VectorMap)currentMap);
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported AutoAdjust Filter: " + filter.GetType() +
                                                        " for Map: " + currentMap.GetType());
                    }
                    return(currentMap);
                }

                if (currentMap is RawBGGRMap <ushort> )
                {
                    if (filter is IRawToColorMap16Filter <RawBGGRMap <ushort>, ushort> )
                    {
                        currentMap = ApplyRawBGGRToColorMapFilter((RawBGGRMap <ushort>)currentMap,
                                                                  (IRawToColorMap16Filter <RawBGGRMap <ushort>, ushort>)filter);
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported Filter: " + filter.GetType() + " for Map: " +
                                                        currentMap.GetType());
                    }
                }
                else if (currentMap is ColorMapUshort)
                {
                    if (filter is IndependentComponentColorToColorFilter <float, float> )
                    {
                        indColorFilter.Add((IndependentComponentColorToColorFilter <float, float>)filter);
                    }
                    else if (filter is IndependentComponentVectorToVectorFilter)
                    {
                        indVectorFilter.Add((IndependentComponentVectorToVectorFilter)filter);
                    }
                    else if (filter is ColorToColorFilter <float, byte> )
                    {
                        currentMap = ApplyIndependentColorFiltersWithRGB((ColorMapUshort)currentMap,
                                                                         indColorFilter, (IndependentComponentColorToColorFilter <float, byte>)filter);
                    }
                    else if (filter is ColorToColorFilter <float, float> )
                    {
                        currentMap = ApplyIndependentColorToFloatFilters((ColorMapUshort)currentMap,
                                                                         indColorFilter);
                        ApplySingleFilterInplace((ColorMap <float>)currentMap, (ColorToColorFilter <float, float>)filter);
                    }
                    else if (filter is VectorToColorFilter <byte> )
                    {
                        currentMap = ApplyIndependentVectorFiltersWithRGB((ColorMapUshort)currentMap,
                                                                          indVectorFilter, (IndependentComponentVectorToColorFilter <byte>)filter);
                    }
                    else if (filter is VectorToVectorFilter)
                    {
                        currentMap = ApplyIndependentColorToVectorFilters((ColorMapUshort)currentMap,
                                                                          indVectorFilter);
                        ApplySingleFilterInplace((VectorMap)currentMap, (VectorToVectorFilter)filter);
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported Filter: " + filter.GetType() + " for Map: " +
                                                        currentMap.GetType());
                    }
                }
                else if (currentMap is ColorMapFloat)
                {
                    if (filter is ColorToColorFilter <float, float> )
                    {
                        ApplySingleFilterInplace((ColorMapFloat)currentMap, (ColorToColorFilter <float, float>)filter);
                    }
                    else if (filter is ColorToColorFilter <float, byte> )
                    {
                        currentMap = ConvertToRGB((ColorMapFloat)currentMap, (ColorToColorFilter <float, byte>)filter);
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported Filter: " + filter.GetType() + " for Map: " +
                                                        currentMap.GetType());
                    }
                }
                else if (currentMap is VectorMap)
                {
                    if (filter is VectorToVectorFilter)
                    {
                        ApplySingleFilterInplace((VectorMap)currentMap, (VectorToVectorFilter)filter);
                    }
                    else if (filter is VectorToColorFilter <byte> )
                    {
                        currentMap = ConvertToRGB((VectorMap)currentMap, (VectorToColorFilter <byte>)filter);
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported Filter: " + filter.GetType() + " for Map: " +
                                                        currentMap.GetType());
                    }
                }
                else
                {
                    throw new NotSupportedException("Not supported Map: " + currentMap.GetType());
                }
            }
            return(currentMap);
        }
Example #3
0
 public void AutoAdjust(RawMap<ushort> map, IIAutoAdjustableFilter autoFilter)
 {
     ProcessFilters(map, autoFilter);
 }
Example #4
0
 public void AutoAdjust(RawMap <ushort> map, IIAutoAdjustableFilter autoFilter)
 {
     ProcessFilters(map, autoFilter);
 }