Ejemplo n.º 1
0
        /// <summary>
        /// Returns the image mean for the ImageSet.
        /// </summary>
        /// <param name="log">Specifies the Log used to output status.</param>
        /// <param name="rgAbort">Specifies a set of wait handles for aborting the operation.</param>
        /// <param name="bQueryOnly">Specifies whether or not to only query for the mean and not calculate if missing.</param>
        /// <returns>The SimpleDatum with the image mean is returned.</returns>
        public SimpleDatum GetImageMean(Log log, WaitHandle[] rgAbort, bool bQueryOnly)
        {
            if (m_imgMean != null || bQueryOnly)
            {
                return(m_imgMean);
            }

            int nLoadedCount = GetLoadedCount();
            int nTotalCount  = GetTotalCount();

            if (nLoadedCount < nTotalCount)
            {
                double dfPct = (double)nLoadedCount / (double)nTotalCount;

                if (log != null)
                {
                    log.WriteLine("WARNING: Cannot create the image mean until all images have loaded - the data is currently " + dfPct.ToString("P") + " loaded.");
                }

                return(null);
            }

            if (OnCalculateImageMean != null)
            {
                CalculateImageMeanArgs args = new CalculateImageMeanArgs(m_rgImages);
                OnCalculateImageMean(this, args);

                if (args.Cancelled)
                {
                    return(null);
                }

                m_imgMean = args.ImageMean;
                return(m_imgMean);
            }

            RawImageMean imgMean = m_factory.GetRawImageMean();

            if (m_imgMean != null)
            {
                m_imgMean = m_factory.LoadDatum(imgMean);
            }
            else
            {
                log.WriteLine("Calculating mean...");
                m_imgMean = SimpleDatum.CalculateMean(log, m_rgImages, rgAbort);
                m_factory.PutRawImageMean(m_imgMean, true);
            }

            m_imgMean.SetLabel(0);

            return(m_imgMean);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the image mean for the ImageSet.
        /// </summary>
        /// <param name="log">Specifies the Log used to output status.</param>
        /// <param name="rgAbort">Specifies a set of wait handles for aborting the operation.</param>
        /// <returns>The SimpleDatum with the image mean is returned.</returns>
        public SimpleDatum GetImageMean(Log log, WaitHandle[] rgAbort)
        {
            if (m_imgMean != null)
            {
                return(m_imgMean);
            }

            if (m_rgImages.Length == 0)
            {
                if (log != null)
                {
                    log.WriteLine("WARNING: Cannot create image mean with no images!");
                }
                return(null);
            }

            if (m_loadMethod != IMAGEDB_LOAD_METHOD.LOAD_ALL)
            {
                throw new Exception("Can only create image mean when using LOAD_ALL.");
            }

            if (m_nLoadLimit != 0)
            {
                throw new Exception("Can only create image mean when LoadLimit = 0.");
            }

            if (OnCalculateImageMean != null)
            {
                CalculateImageMeanArgs args = new CalculateImageMeanArgs(m_rgImages);
                OnCalculateImageMean(this, args);

                if (args.Cancelled)
                {
                    return(null);
                }

                m_imgMean = args.ImageMean;
                return(m_imgMean);
            }

            m_imgMean = SimpleDatum.CalculateMean(log, m_rgImages, rgAbort);
            m_imgMean.SetLabel(0);

            return(m_imgMean);
        }