예제 #1
0
        /// <summary>
        /// Draw channel image
        /// </summary>
        /// <param name="bitplane">bitplane of current image</param>
        /// <param name="ch">current channel</param>
        /// <param name="numCh">total number of channels</param>
        /// <returns>Image</returns>
        public static Bitmap getChannelImage(MyBitplane bitplane, int ch, int numCh)
        {
            MyImage myImage = new MyImage(bitplane.Width, bitplane.Height, numCh);

            myImage.Bitplane[ch] = bitplane;

            return(myImage.GetBitmap());
        }
예제 #2
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Parameters parameters = (Parameters)e.Argument;
                watch = Stopwatch.StartNew();

                // Load image
                using (Bitmap image = new Bitmap(parameters.filename))
                {
                    // Convert to MyImage
                    myImage               = new MyImage(image);
                    histograms            = new double[myImage.NumCh][];
                    comulativeFrequencies = new double[myImage.NumCh][];
                    channelImages         = new Bitmap[myImage.NumCh];

                    // Do paralel image process on each channel
                    Parallel.ForEach(myImage.Bitplane, (bitplane, state, ch) =>
                    {
                        // Process current channel
                        ImageProcessing.processImage(ref bitplane, parameters.algorithm, parameters.windowSize, parameters.contrastLimit);

                        // Calculate Histogram
                        histograms[ch] = ImageProcessing.calculateHistogram(bitplane);

                        // Calculate Comulative Histogram
                        comulativeFrequencies[ch] = ImageProcessing.calculateComulativeFrequency(histograms[ch]);

                        // Get image by channels
                        channelImages[ch] = ImageRendering.getChannelImage(bitplane, (int)ch, myImage.NumCh);
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }