예제 #1
0
        /// <summary>
        /// Get the filter response images from exEl
        /// </summary>
        /// <param name="exEl"></param>
        /// <returns></returns>
        private Image GetData(ExchangeElement exEl, LBPFilter lbpFilter)
        {
            int nHeight = exEl.Height;
            int nWidth  = exEl.Width;

            int i;

            char[] charArr = new char[exEl.ByteData.GetLength(0)];
            for (i = 0; i < exEl.ByteData.GetLength(0); i++)
            {
                charArr[i] = Convert.ToChar(exEl.ByteData[i]);
            }

            Image dpuImgData = new Image(charArr, nWidth, nHeight);
            Image rstImgData = null;

            if ((_imgWidth != nWidth) || (_imgHeight != nHeight))
            {
                rstImgData = new Dpu.ImageProcessing.Image(_imgWidth, _imgHeight);
                Image.BilinearResample(dpuImgData, rstImgData);
            }
            else
            {
                rstImgData = dpuImgData;
            }

            dpuImgData = new Image(_imgWidth, _imgHeight);
            lbpFilter.FilterImage(rstImgData, dpuImgData);

            return(dpuImgData);
        }
예제 #2
0
        /// <summary>
        /// Read the image data from ExchangeElement, subject to the transform, i.e., reSize, downsampling, etc.
        /// specified by the parameters.
        /// </summary>
        /// <param name="exEl">element in DataExchange</param>
        /// <returns></returns>
        private INumArray <double> GetData(ExchangeElement exEl)
        {
            INumArray <double> data;
            int nHeight = exEl.Height;
            int nWidth  = exEl.Width;

            int i, j;
            int ipx = 0;

            if (m_bResize)
            {
                //if m_bResize=true, resize the data to certain size
                char[] charArr = new char[exEl.ByteData.GetLength(0)];
                for (i = 0; i < exEl.ByteData.GetLength(0); i++)
                {
                    charArr[i] = Convert.ToChar(exEl.ByteData[i]);
                }


                Dpu.ImageProcessing.Image dpuImgData = new Dpu.ImageProcessing.Image(charArr, nWidth, nHeight);
                Dpu.ImageProcessing.Image rstImgData = new Dpu.ImageProcessing.Image(m_iReSizeWidth, m_iReSizeHeight);
                Dpu.ImageProcessing.Image.BilinearResample(dpuImgData, rstImgData);

                data = ArrFactory.DoubleArray(m_iReSizeHeight, m_iReSizeWidth);
                float[] pixelData = rstImgData.Pixels;
                ipx = 0;
                for (i = 0; i < m_iReSizeHeight; i++)
                {
                    for (j = 0; j < m_iReSizeWidth; j++)
                    {
                        data[i, j] = Convert.ToDouble(pixelData[ipx]);
                        ipx       += 1;
                    }
                }
            }
            else
            {
                if (m_bDownSample)
                {
                    data = ArrFactory.DoubleArray(nHeight / 2, nWidth / 2);
                    ipx  = 0;
                    Byte[] imData = exEl.ByteData;
                    for (i = 0; i < nHeight; i++)
                    {
                        for (j = 0; j < nWidth; j++)
                        {
                            data[i, j] = Convert.ToDouble(imData[ipx]);
                            ipx       += 2;
                        }
                    }
                }
                else
                {
                    data = ArrFactory.DoubleArray(exEl.DoubleDataMatrix);
                }
            }

            if (m_bGlocalTrans)
            {
                data = DataTransform.GlocalTransform(data, _localWidth, _localHeight);
            }

            return(data);
        }