Example #1
0
 public void Initialize(Object passedObj)
 {
     BufferParameter bufferParam = passedObj as BufferParameter;
     if (bufferParam != null)
     {
         _Effect = bufferParam.dockPanel.Effect as XrayImageEffect;
         m_History = bufferParam.History;
     }
 }
Example #2
0
        public XRayView ()
        {
            InitializeComponent();
            CultureResources.registerDataProvider(this);

            CultureResources.getDataProvider().DataChanged += new EventHandler(CultureResources_DataChanged);

            PseudoColorPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins\\PseudoColor\\";
            _AdornerLayerManager = new AdornerLayerManager(AdornerLayer.GetAdornerLayer(PanAndZoomControl));
            _XrayImageEffect = new XrayImageEffect();
             
            XrayImage_Panel.Effect = _XrayImageEffect;
        }
Example #3
0
        public void Setup (XrayImageEffect effect, Image image, History history, float[] data)
        {
            _Effect = effect;

            m_History = history;
            m_History.CurrentHistoryChangedEvent += new CurrentHistoryChanged(ApplyHistory);

            HistoryHistogram histogram = new HistoryHistogram();
            histogram.effecttype = "Gray";
            histogram.start = rangeSlider.RangeStart;
            histogram.end = rangeSlider.RangeStop;
            m_History.SetFirstStep(histogram);

            SetDataPoints(image, data);

            m_History.ApplyStep();
        }
Example #4
0
        public static void RenderXrayImage_XRayImageEffect(ref BitmapSource bsource, XrayImageEffect xrayImageEffect, SourceObject sourceObject)
        {
            //BitmapSource bsource = XRay_Image.Source as BitmapSource;

            PixelFormat pixelFormat = PixelFormats.Bgr24;

            int pixelOffset = pixelFormat.BitsPerPixel / 8;
            int stride = sourceObject.Width * pixelOffset;

            byte[] newData = new byte[sourceObject.Data.Length * pixelOffset];

            double min = xrayImageEffect.LowerBound;
            double max = xrayImageEffect.UpperBound;

            Color lowerBoundColor = xrayImageEffect.LowerBoundColor;
            Color upperBoundColor = xrayImageEffect.UpperBoundColor;

            bool enableSQRT = xrayImageEffect.EnableSquareroot > 0 ? true : false;
            bool enableSQRE = xrayImageEffect.EnableSquare > 0 ? true : false;

            Parallel.For(0, sourceObject.Data.Length, i =>
            {
                float data = sourceObject.Data[i];
                Color color = new Color();

                if (data < min)
                {
                    color.ScB = (data * lowerBoundColor.ScB);
                    color.ScG = (data * lowerBoundColor.ScG);
                    color.ScR = (data * lowerBoundColor.ScR);
                }
                else if (data > max)
                {
                    if (upperBoundColor == Colors.White)
                    {
                        color.ScB = 1.0F;
                        color.ScG = 1.0F;
                        color.ScR = 1.0F;
                    }
                    else
                    {
                        color.ScB = (data * upperBoundColor.ScB);
                        color.ScG = (data * upperBoundColor.ScG);
                        color.ScR = (data * upperBoundColor.ScR);
                    }
                }
                else if (enableSQRT)
                {
                    double Diff = max - min;
                    color.ScR = color.ScG = color.ScB = (float)(Math.Sqrt(16777216 * ((data - min) / Diff)) / Math.Sqrt(16777216));
                }
                else if (enableSQRE)
                {
                    double Diff = max - min;
                    color.ScR = color.ScG = color.ScB = (float)Math.Pow(((data - min) / Diff), 2);
                }
                else
                {
                    double Diff = max - min;
                    color.ScR = color.ScG = color.ScB = (float)((data - min) / Diff);
                }

                newData[i * pixelOffset + 0] = color.B;
                newData[i * pixelOffset + 1] = color.G;
                newData[i * pixelOffset + 2] = color.R;
            });

            bsource = BitmapSource.Create(sourceObject.Width, sourceObject.Height, 96.0, 96.0, pixelFormat, null, newData, stride);
        }