示例#1
0
        public cVolumeRendering3D(cSingleChannelImage SingleChannelImage, cPoint3D Pos, byte[][] NewLUT)
        {
            this.LUT = NewLUT;

            vtk_volume = vtkVolume.New();
            vtk_volume.PickableOn();
            vtkImageData imageData = vtkImageData.New();
            vtkUnsignedShortArray UshortArray = vtkUnsignedShortArray.New();

            vtkExtractVOI voi = vtkExtractVOI.New();
            vtkPiecewiseFunction opacityTransferFunction = vtkPiecewiseFunction.New();
            vtkColorTransferFunction colorTransferFunction = vtkColorTransferFunction.New();
            vtkVolumeProperty volumeProperty = vtkVolumeProperty.New();

            for (int i = 0; i < SingleChannelImage.Width * SingleChannelImage.Height * SingleChannelImage.Depth; i++)
            {
                UshortArray.InsertTuple1(i, (ushort)SingleChannelImage.Data[i]);
            }

            imageData = vtkImageData.New();
            imageData.SetDimensions(SingleChannelImage.Width, SingleChannelImage.Height, SingleChannelImage.Depth);
            imageData.SetOrigin(0, 0, 0);

            if ((SingleChannelImage.Resolution.X == 0) || (SingleChannelImage.Resolution.Y == 0) || (SingleChannelImage.Resolution.Z == 0))
                imageData.SetSpacing(1.0, 1.0, 1.0);
            else
                imageData.SetSpacing(SingleChannelImage.Resolution.X, SingleChannelImage.Resolution.Y, SingleChannelImage.Resolution.Z);

            imageData.GetPointData().SetScalars(UshortArray);

            voi = vtkExtractVOI.New();
            voi.SetInput(imageData);
            voi.SetVOI(0, SingleChannelImage.Width - 1, 0, SingleChannelImage.Height - 1, 0, SingleChannelImage.Depth - 1);
            voi.SetSampleRate(1, 1, 1);

            opacityTransferFunction = vtkPiecewiseFunction.New();

            range = imageData.GetScalarRange();
            opacityTransferFunction.AddPoint(0, 0.0);
            opacityTransferFunction.AddPoint(255, 1);
            //opacityTransferFunction.AddPoint(range[0] + (range[1]-range[0])/2.0, 0.0);
            //opacityTransferFunction.AddPoint(range[1], 0.7);

            if (LUT == null)
            {
                cLUT MyLut = new cLUT();
                LUT = MyLut.LUT_JET;
            }

            double LUTSize = LUT[0].Length;

            for (int i = 0; i < (int)LUTSize - 1; i++)
            {
                colorTransferFunction.AddRGBPoint(i, this.LUT[0][i] / LUTSize, this.LUT[1][i] / LUTSize, this.LUT[2][i] / LUTSize);
            }

            colorTransferFunction.Build();

            volumeProperty = vtkVolumeProperty.New();
            volumeProperty.SetColor(colorTransferFunction);
            volumeProperty.SetScalarOpacity(opacityTransferFunction);
            volumeProperty.SetInterpolationTypeToLinear();
            volumeProperty.ShadeOff();
            volumeProperty.SetAmbient(0.6);
            volumeProperty.SetDiffuse(0.6);
            volumeProperty.SetSpecular(0.1);

            vtkVolumeTextureMapper3D volumeTextureMapper = vtkVolumeTextureMapper3D.New();
            volumeTextureMapper.SetInputConnection(voi.GetOutputPort());

            //vtkVolumeRayCastCompositeFunction compositeFunction = vtkVolumeRayCastCompositeFunction.New();
            //vtkVolumeRayCastMapper volumeMapper = vtkVolumeRayCastMapper.New();
            //volumeMapper.SetVolumeRayCastFunction(compositeFunction);
            //volumeMapper.SetInputConnection(voi.GetOutputPort());

            vtk_volume = vtkVolume.New();
            vtk_volume.SetMapper(volumeTextureMapper);
            vtk_volume.SetProperty(volumeProperty);
            vtk_volume.PickableOn();

            vtk_volume.SetPosition(Pos.X, Pos.Y, Pos.Z);
        }
示例#2
0
        cFeedBackMessage Process()
        {
            if (base.Start() == false)
            {
                base.FeedBackMessage.IsSucceed = false;
                return base.FeedBackMessage;
            }

            object _firstValue = base.ListProperties.FindByName("Include Images?");
            bool IsIncludeImages = false;
            if (_firstValue == null)
            {
                base.GenerateError("-Include Images?- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                IsIncludeImages = (bool)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Include Images?- cast didn't work");
                return base.FeedBackMessage;
            }

            this.Output = this.Input.GetAverageDescriptorValuesFull();

            if (IsIncludeImages)
            {
                this.Output.ListTags = new List<object>();

                foreach (cWell item in Input)
                {
                    cGetImageFromWells GIFW = new cGetImageFromWells();
                    GIFW.SetInputData(new cListWells(this));
                    if (!GIFW.Run().IsSucceed) continue;
                    cImage AccessedImage = GIFW.GetOutPut();

                    List<byte[][]> ListLUTs = new List<byte[][]>();
                    cLUT LUT = new cLUT();
                    ListLUTs.Add(LUT.LUT_LINEAR_RED);
                    ListLUTs.Add(LUT.LUT_LINEAR_GREEN);
                    ListLUTs.Add(LUT.LUT_LINEAR_BLUE);

                    List<double> ListMin = new List<double>();
                    ListMin.Add(200);
                    ListMin.Add(200);

                    List<double> ListMax = new List<double>();
                    ListMax.Add(65530);
                    ListMax.Add(5000);

                    cImageDisplayProperties IP = new cImageDisplayProperties();
                    IP.ListMax = ListMax;
                    IP.ListMin = ListMin;

                    this.Output.ListTags.Add(AccessedImage.GetBitmap(0.2f, IP, ListLUTs));
                }

            }

            base.End();

            return FeedBackMessage;

            //// here is the core of the meta component ...
            //// just a list of Component steps
            //foreach (cWell item in Input)
            //{
            //    item.AssociatedPlate.DBConnection = new cDBConnection(item.AssociatedPlate, item.SQLTableName);
            //    cListSingleBiologicalObjects ListPhenotypes = item.AssociatedPlate.DBConnection.GetBiologicalPhenotypes(item);
            //    cExtendedTable ET = item.AssociatedPlate.DBConnection.GetWellValues(item, cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors());
            //    item.AssociatedPlate.DBConnection.CloseConnection();

            //    ET.ListTags = new List<object>();

            //    for (int i = 0; i < ET.Count; i++)
            //    {
            //        ET[i].ListTags = new List<object>();

            //        for (int j = 0; j < ListPhenotypes.Count; j++)
            //            ET[i].ListTags.Add(ListPhenotypes[j]);
            //    }

            //    for (int j = 0; j < ListPhenotypes.Count; j++)
            //        ET.ListTags.Add(ListPhenotypes[j]);

            //    if (Output == null)
            //        Output = new cExtendedTable(ET);
            //    else
            //    {
            //        cMerge M = new cMerge();
            //        M.IsHorizontal = false;
            //        M.SetInputData(Output, ET);
            //        M.Run();

            //        Output = M.GetOutPut();
            //    }
            //}
        }
示例#3
0
        public int AddBiological3DObjects(List<cInteractive3DObject> object3DList, Color Colour, IM3_Plugin3.Plugin3D.eColorMode ColorMode)
        {
            int NumObj = 0;

            if (ColorMode == IM3_Plugin3.Plugin3D.eColorMode.Random)
            {
                Random random = new Random();
                for (int i = 0; i < object3DList.Count; i++)
                {
                    if (object3DList[i] == null) continue;
                    NumObj++;

                    double R = random.NextDouble();
                    double G = random.NextDouble();
                    double B = random.NextDouble();

                    //object3DList[i].GetActor().GetProperty().SetColor(R, G, B);
                    object3DList[i].Colour = Color.FromArgb((int)(R * 255), (int)(G * 255), (int)(B * 255));
                    AddBiological3DObject(object3DList[i]);
                }
            }
            else if (ColorMode == IM3_Plugin3.Plugin3D.eColorMode.Regular)
            {
                for (int i = 0; i < object3DList.Count; i++)
                {
                    if (object3DList[i] == null) continue;
                    NumObj++;

                   // object3DList[i].GetActor().GetProperty().SetColor(Colour.R / 255.0, Colour.G / 255.0, Colour.B / 255.0);
                    object3DList[i].Colour = Colour;
                    AddBiological3DObject(object3DList[i]);
                }
            }
            else
            {
                cLUT LUT = new cLUT();

                byte[][] CurrentLUT = LUT.LUT_JET;

                for (int i = 0; i < object3DList.Count; i++)
                {
                    if (object3DList[i] == null) continue;
                    NumObj++;
                    int ConvertedValue = (int)(((CurrentLUT[0].Length - 1) * i) / object3DList.Count);
                    //object3DList[i].GetActor().GetProperty().SetColor(CurrentLUT[0][ConvertedValue] / 255.0, CurrentLUT[1][ConvertedValue] / 255.0, CurrentLUT[2][ConvertedValue] / 255.0);

                    object3DList[i].Colour = Color.FromArgb(CurrentLUT[0][ConvertedValue], CurrentLUT[1][ConvertedValue], CurrentLUT[2][ConvertedValue]);
                    AddBiological3DObject(object3DList[i]);
                }
            }

            return NumObj;
        }