Mostrando postagens com marcador Processamento de Imagens. Mostrar todas as postagens
Mostrando postagens com marcador Processamento de Imagens. Mostrar todas as postagens

quinta-feira, 25 de novembro de 2010

Processamento de Imagens – Udesc 2010

Contagem de Arestas (EdgesCount.xaml.cs)

gear

image

 

EdgesCount.xaml.cs

 

Bitmap originalImage;

        private void buttonExecute_Click(object sender, RoutedEventArgs e)
        {
            Bitmap erodedImage, differenceImage, finalImage;
            //standardizes the colors in black or white
            originalImage = Equalize(ref originalImage);
            //make the erosion in the original image
            erodedImage = Erosion(ref originalImage, Convert.ToInt32(textBoxSize.Text));
            imageEroded.Source = Util.ConvertImage(erodedImage);
            //take the difference between original image and eroded image
            differenceImage = Difference(ref originalImage,ref erodedImage);
            imageDifference.Source = Util.ConvertImage(differenceImage);
            //make the erosion in the differenceImage to separate edges
            finalImage = Erosion(ref differenceImage, Convert.ToInt32(textBoxSize2.Text));
            imageFinal.Source = Util.ConvertImage(finalImage);
            //Count the edges with region growing recursively taking the difference until the image not have segments to count
            textBlockTotal.Text = EdgeQuantity(ref finalImage);

        }

 

  • Exercício 2 - Criação de imagens sintéticas

    Crie uma imagem em forma de xadrez com dimensões M linhas x N colunas, na qual cada retângulo interno do xadrez tenha m linhas x n colunas.

    image

  • Exercício 3 - Mapa de cores e pseudocoloração

    Pseudocoloração

    Crie uma função meu_mapa para gerar um mapa de cores RGB qualquer (use sua criatividade) e uma função aplica_mapa para efetuar pseudocoloração em uma imagem em níveis de cinza (exemplos de aplicações: realce de imagens de raio X, médicas, astronômicas, gráficos, etc). Referência: colormap do matlab.

    image

  • Exercício 4 - Filtragem - convolução periódica
  • Convolução

    Implente a convolução periódica.

  • image

     

  • Questão 5 - Questão 5 da prova 1
  • image
  • http://fernando-magno.blogspot.com/2010/09/deteccao-de-pupila.html

     

  • Exercício 5 - Transformada de Fourier
  • Implemente filtros ideais passa-baixa, passa-alta e passa-faixa;

    image

  • Exercício 6 - Restauração de imagens
    1. Provocar uma degradação com um filtro qualquer (suficientemente grande).
    2. Procurar restaurar a imagem com um filtro inverso R(u,v) e filtro de Wiener (equação abaixo).
  • Exercício 7 - Ampliação e redução de imagens

    Implementação de redução e ampliação de imagens usando interpolação por filtro de Butterworth.

    image

  • Exercício 8 - Crescimento de regiões

    Implementação de redução e ampliação de imagens usando interpolação por filtro de Butterworth.

    image

    image

    image

  • Exercício 9 – Rotulação

    Implementação e testes da rotulação de imagens binárias. A rotulação consiste na atribuição de um valor inteiro diferente para cada componente conexo.

    image

    image

    image

  • Exercício 10 - Gradiente e transformada de distância
  • Implementação e testes do gradiente morfológico (GM).
  • Exercício 11 - Afinamento morfológico
  • Implemente e teste o afinamento morfológico.
  • image
  • 2 passadas
  • image
  • 5 passadas
  • image

    10 passadas

     

    Projeto Final

    Contagem de Veículos

    image

  • quinta-feira, 2 de setembro de 2010

    Detecção de Pupila

    Instalador: http://easycomtec.com/magno/pi.rar

    Código Fonte: http://easycomtec.com/magno/pi%20source.rar

    Imagem: http://easycomtec.com/magno/image1.jpg

    image

     

           string filepath;
           int limiteInferiorX = -1;
           int limiteInferiorY = -1;
           int limiteSuperiorX = -1;
           int limiteSuperiorY = -1;

           int pontoX1 = -1;
           int pontoY1 = -1;
           int pontoX2 = -1;
           int pontoY2 = -1;

           public MainWindow()
           {
               InitializeComponent();
           }

           private void button1_Click(object sender, RoutedEventArgs e)
           {
               var imagemTratada = Pupila(new Bitmap(filepath));
               var maiorDistancia = MaiorDistancia(imagemTratada);
               var raio = maiorDistancia / 2;
               var centroX = (pontoX2 + pontoX1) / 2;
               var centroY = (pontoY2 + pontoY1) / 2;
               label1.Content = String.Format("Raio:{0} Centro (X,Y):({1},{2})", raio, centroX, centroY);

               var originalImage = new Bitmap(filepath);

               for (int x = centroX - 2; x < centroX + 2; x++)
               {
                   for (int y = centroY - 2; y < centroY + 2; y++)
                   {
                       imagemTratada.SetPixel(x, y, System.Drawing.Color.Red);
                       originalImage.SetPixel(x, y, System.Drawing.Color.Red);

                   }
               }

               image1.Source = ConvertImage(imagemTratada);
               image2.Source = ConvertImage(originalImage);
           }

           private Bitmap Pupila(Bitmap image)
           {
               for (int x = 0; x < image.Width; x++)
               {
                   for (int y = 0; y < image.Height; y++)
                   {
                       var color = image.GetPixel(x,y);
                       var value = (color.R + color.G + color.B) /3;
                       if (value < 50)
                       {
                           if (limiteInferiorX < 0)
                           {
                               limiteInferiorX = x;
                               limiteInferiorY = y;
                           }

                           if (limiteSuperiorX < x)
                           {
                               limiteSuperiorX = x;
                           }

                           if (limiteSuperiorY < y)
                           {
                               limiteSuperiorY = y;
                           }

                           image.SetPixel(x, y, System.Drawing.Color.Black);
                       }
                       else
                       {
                           image.SetPixel(x, y, System.Drawing.Color.White);
                       }
                   }
               }

               return image;
           }

           private double MaiorDistancia(Bitmap image)
           {
               double maiorValor = 0;
               double aux;
               for (int x1 = limiteInferiorX; x1 < limiteSuperiorX; x1++)
               {
                   for (int y1 = limiteInferiorY; y1 < limiteSuperiorY; y1++)
                   {
                       if (image.GetPixel(x1, y1).R == 0)
                       {
                           for (int x2 = x1; x2 < limiteSuperiorX; x2++)
                           {
                               for (int y2 = y1; y2 < limiteSuperiorY; y2++)
                               {
                                   if (image.GetPixel(x2, y2).R == 0)
                                   {
                                       aux = EuclidianaDistancia(x1, y1, x2, y2);
                                       if (aux > maiorValor)
                                       {
                                           maiorValor = aux;

                                           pontoX1 = x1;
                                           pontoX2 = x2;
                                           pontoY1 = y1;
                                           pontoY2 = y2;
                                       }
                                   }
                               }
                           }
                       }
                   }
               }

               return maiorValor;
           }

           private double EuclidianaDistancia(int x1, int y1, int x2 , int y2)
           {
               return Math.Sqrt((Math.Pow((x1 - x2), 2) + Math.Pow((y1 - y2), 2)));
           }

     

           private System.Drawing.Color VerifyColor(int x, double factor,ref System.Drawing.Color color)
           {
               if (x % factor == 0)
               {
                   if (color == System.Drawing.Color.Black)
                   {
                       color = System.Drawing.Color.White;
                   }
                   else
                   {
                       color = System.Drawing.Color.Black;
                   }
               }

               return color;
           }  

           private ImageSource ConvertImage(Bitmap image)
           {
               MemoryStream ms = new MemoryStream();

               image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

               System.Windows.Media.Imaging.BitmapImage bImg = new System.Windows.Media.Imaging.BitmapImage();

               bImg.BeginInit();

               bImg.StreamSource = new MemoryStream(ms.ToArray());

               bImg.EndInit();

               return bImg;
           }

           private void buttonLoad_Click(object sender, RoutedEventArgs e)
           {
               OpenFileDialog openFileDialog1 = new OpenFileDialog();

               if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
               {
                   filepath = openFileDialog1.FileName;
                   image1.Source = ConvertImage(new Bitmap(filepath));
               }

           }