Exemplo n.º 1
0
        public static List <DcCategoryEncodedPair> GetAllDCs(ColorChannel channel)
        {
            List <DcCategoryEncodedPair> result = new List <DcCategoryEncodedPair>(channel.GetNumOfBlocks());

            for (int i = 0; i < channel.GetNumOfBlocks(); i++)
            {
                result.Add(CalculateDifferenceDc(channel, i));
            }

            return(result);
        }
Exemplo n.º 2
0
 private void QuantizeChannel(ColorChannel channel, DoubleMatrix quantizationTable)
 {
     for (int i = 0; i < channel.GetNumOfBlocks(); i++)
     {
         CosineTransformation.Quantize(channel.GetBlock(i), quantizationTable);
     }
 }
Exemplo n.º 3
0
        private CountdownEvent TransformChannel(ColorChannel channel)
        {
            CountdownEvent e          = new CountdownEvent(1);
            int            blockCount = channel.GetNumOfBlocks();

            if (blockCount < 500 >> 4)
            {
                for (int i = 0; i < channel.GetNumOfBlocks(); i++)
                {
                    Arai.Calc(channel.GetBlock(i));
                }
            }
            else
            {
                int threadCount = 8;

                if (blockCount < 1000 >> 4)
                {
                    threadCount = 4;
                }

                for (int i = 0; i < blockCount; i += blockCount / threadCount)
                {
                    e.AddCount();
                    ThreadPool.QueueUserWorkItem(
                        state =>
                    {
                        object[] inp = state as object[];

                        //Console.WriteLine($"Thread with block {(int) inp[0]} to block {(int) inp[1]} started...");

                        int upper = (int)inp[1];

                        for (int j = (int)inp[0]; j < upper; j++)
                        {
                            Arai.Calc(channel.GetBlock(j));
                        }

                        e.Signal();
                    }, new object[] { i, i + (blockCount / threadCount) });
                }
            }

            e.Signal();
            return(e);
        }
Exemplo n.º 4
0
        public static List <AcCategoryEncodedPair> GetAllACs(ColorChannel channel)
        {
            List <AcCategoryEncodedPair> result = new List <AcCategoryEncodedPair>();

            for (int i = 0; i < channel.GetNumOfBlocks(); i++)
            {
                DoubleMatrix block = channel.GetBlock(i);
                List <AcRunlengthEncodedPair> runLengthEncodedBlock = EncodeRunlength(Util.ZigzagSort(block));
                List <AcCategoryEncodedPair>  categoryEncodedBlock  = EncodeCategoriesAc(runLengthEncodedBlock);
                result.AddRange(categoryEncodedBlock);
            }

            return(result);
        }
        public int Call()
        {
            int       count     = 0;
            Stopwatch stopwatch = Stopwatch.StartNew();

            while (stopwatch.ElapsedMilliseconds < 10000)
            {
                foreach (DoubleMatrix block in _channel.GetBlocks(0, _channel.GetNumOfBlocks()))
                {
                    DCT.Advanced(block);
                }

                count++;
            }

            stopwatch.Stop();
            return(count);
        }