Beispiel #1
0
        private void RefImageListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (RefImageListBox.SelectedItem == null)
            {
                return;
            }

            if (RefImageListBox.SelectedItem.GetType() == typeof(ReferenceImageContainer))
            {
                ReferenceImageContainer ric = (ReferenceImageContainer)RefImageListBox.SelectedItem;

                if (ric.ImageData != null)
                {
                    if (ric.Width != m_vm.width2 || ric.Height != m_vm.height2)
                    {
                        m_vm.width2  = (ushort)ric.Width;
                        m_vm.height2 = (ushort)ric.Height;
                        m_vm.bitmap2 = BitmapFactory.New(m_vm.width2, m_vm.height2);
                    }

                    m_imageTool.PostFullGrayscaleImage(ric.ImageData, m_vm.width2, m_vm.height2);

                    m_imageTool.Convert_GrayscaleToColor(m_rangeLower2, m_rangeUpper2);

                    m_imageTool.Download_ColorImage(out m_colorImageData2, m_vm.width2, m_vm.height2);

                    // display the image
                    Int32Rect displayRect = new Int32Rect(0, 0, m_vm.width2, m_vm.height2);
                    m_vm.bitmap2.Lock();
                    m_vm.bitmap2.WritePixels(displayRect, m_colorImageData2, m_vm.width2 * 4, 0);
                    m_vm.bitmap2.Unlock();



                    // calculate the image histogram
                    UInt32[] histogram;
                    m_imageTool.GetHistogram_512(out histogram, 16);

                    // build the histogram image and download it to the CPU
                    byte[] histImage;
                    m_imageTool.GetHistogramImage_512(out histImage, m_histogramImageWidth, m_histogramImageHeight, 0);

                    // display the histogram image
                    m_vm.histImage2 = BitmapFactory.New(m_histogramImageWidth, m_histogramImageHeight);
                    Int32Rect histRect = new Int32Rect(0, 0, m_histogramImageWidth, m_histogramImageHeight);
                    m_vm.histImage2.Lock();
                    m_vm.histImage2.WritePixels(histRect, histImage, m_histogramImageWidth * 4, 0);
                    m_vm.histImage2.Unlock();
                    HistImage.Source = m_vm.histImage2;
                }
            }
        }