Beispiel #1
0
        private static Dictionary <string, InterpretationFromImage> InitializeInterpretations(List <LayerWrapper> layers)
        {
            var interpretationsFromObservations = new Dictionary <String, InterpretationFromImage>();

            foreach (LayerWrapper wrapper in layers)
            {
                IEnumerable <string> libs = wrapper.Layer.AnnotationLibraries();
                if (libs != null)
                {
                    foreach (string lib in libs)
                    {
                        IEnumerable <string> imageids = AnnotationLibrary.GetAllImageIds(lib);
                        foreach (string imageid in imageids)
                        {
                            if (!interpretationsFromObservations.ContainsKey(imageid))
                            {
                                interpretationsFromObservations.Add(imageid, new InterpretationFromImage(AnnotationLibrary.GetImage(lib, imageid)));
                            }
                        }
                    }
                }
            }


            //IEnumerable<string> images = _prefab.GetImages();
            //foreach (JsonData obs in observations)
            //{
            //    interpretationsFromObservations[obs["_id"].ToString()] = new InterpretationFromObservation(obs);
            //}

            return(interpretationsFromObservations);
        }
Beispiel #2
0
        public static string ConfigurationId(List <LayerWrapper> layers, int index)
        {
            int count = 0;
            int end;

            if (index < 0)
            {
                end = layers.Count - 1;
            }
            else
            {
                end = index;
            }



            string id    = "";
            bool   first = true;

            foreach (LayerWrapper layer in layers)
            {
                string annotationids      = "";
                IEnumerable <string> libs = layer.Layer.AnnotationLibraries();


                if (libs != null)
                {
                    List <string> sorted = new List <string>(libs);
                    sorted.Sort();
                    foreach (string lib in sorted)
                    {
                        annotationids += AnnotationLibrary.GetLibraryId(lib);
                    }
                }

                int    parameters = 17;
                string layerid    = layer.Layer.Name + layer.Id + annotationids + parameters;
                if (!first)
                {
                    id += ",";
                }

                first = false;
                id   += layerid;

                if (count == end)
                {
                    break;
                }

                count++;
            }

            return(id);
        }
Beispiel #3
0
        private static List <AnnotatedNode> NodesFromImageAnnotations(List <LayerWrapper> layers,
                                                                      int precedingLayerIndex,
                                                                      Dictionary <string, InterpretationFromImage> interps)
        {
            LayerWrapper currentLayer = layers[precedingLayerIndex + 1];

            List <ImageAnnotation> annotations = new List <ImageAnnotation>();

            IEnumerable <string> layerlibs = currentLayer.Layer.AnnotationLibraries();

            if (layerlibs != null)
            {
                foreach (string lib in layerlibs)
                {
                    annotations.AddRange(AnnotationLibrary.GetAnnotations(lib));
                }
            }

            List <AnnotatedNode> nodesToProcess = new List <AnnotatedNode>();

            //for each one, interpret the observation
            foreach (ImageAnnotation annotation in annotations)
            {
                InterpretationFromImage interp = interps[annotation.ImageId];
                Interpret(layers, precedingLayerIndex, interp);
                Tree root         = interp.interpretation;
                Tree matchingnode = MatchingNode(root, annotation.Region);

                AnnotatedNode annoatednode = new AnnotatedNode(matchingnode, root, annotation.Data, annotation.Region, annotation.ImageId);
                nodesToProcess.Add(annoatednode);
            }

            //MergeNodesWithSameRegion(nodesToProcess);

            return(nodesToProcess);
        }