bonjour tous le monde , bon c mon programme il parle de l'indexation des images et la comparaison entre ces images à travers ces indexes, bon le code suivant marche parfaitement ( voir au dessous ) )...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
 
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            // initialement le programme charge l'image sous documents pour l'indexer , on doit regler ça de façon a charger l'image sous wamp\send_image!!!!!
            pictureBox1.Image = Image.FromFile
            (System.Environment.GetFolderPath
            (System.Environment.SpecialFolder.Personal)
            + @"\test.jpg");
            SourceImage = new Bitmap(pictureBox1.Image);
            DirectoryInfo dir = new DirectoryInfo(@"C:\temp\base_images");
            FileInfo[] bmpfiles = dir.GetFiles("*.jpg");
            listBox2.Items.Add(dir);
 
 
            int totalimages = 0;
            googleresults.Items.Clear();
       for (int i = 1; i <= listBox2.Items.Count; i++)
            {
                listBox2.SetSelected(i - 1, true);
 
                DirectoryInfo dir1 = new DirectoryInfo((string)listBox2.Text.ToString());
                FileInfo[] bmpfiles1 = dir1.GetFiles("*.jpg");
                totalimages = totalimages + bmpfiles1.Length;
 
                for (int j = 0; j <= bmpfiles1.Length - 1; j++)
                {
                    googleresults.Items.Add(listBox2.Text + "\\" + bmpfiles1[j]);
 
                }
            }
 
            ImagesToSearch = new string[totalimages];
 
            for (int i = 0; i < totalimages; i++)
            {
                ImagesToSearch[i] = googleresults.Items[i].ToString();
 
            }
 
 
            textBox18.Text = totalimages.ToString();
 
 }
mais qu'on j'essaye dajouter cette partie , rien ne marche et un message :
Le tableau en entrée est plus long que le nombre de colonnes de cette table.
est affiché juste apres l'instruction == DataResults.Rows.Add(ImagesToSearch[i].ToString(), TotalDeviation);

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
 // Create 2 tables for each descriptor. In the first Table you 
            // keep information about "Source Image" (initial image) and in the second table
            // you keep information about "To Compare" image
            // SOS in this version we do not use multiple threads 
            panel1.Visible = true;
            panel1.Refresh();
            Setlabels("Reading Image", "Please Wait");
            CEDD_Descriptor.CEDD CEDDDescriptor = new CEDD_Descriptor.CEDD();  // using CEDD.DLL
            double[] CEDDTable_Source = new double[144];
            double[] CEDDTable_ToCompare = new double[144];
            int Descriptor = 0;
            // Get the descriptor for the source image
            CEDDTable_Source = CEDDDescriptor.Apply(SourceImage); // GET The CEDD Descriptor for the Initial Image
            // Ok, now you have the descriptor for the images.
 
            // Remember that you can save the descripors for all the images in one XLM type file
            // You can use the Img(Rummager) "manage data" to create these files and then search using these files in order to increase the searching speed
 
            int NumberOfImages = Convert.ToInt32(textBox18.Text.ToString());
            double TotalDeviation = 0; // Here you will store the deviation of the images (pairwise)
            Bitmap ToCompare;
            MPEG_7Simillarity MPEGComparer = new MPEG_7Simillarity(); // Use this class in order to campare images using MPEG-7 Descriptors
            DataResults.Clear(); // Clear the results
 
            for (int i = 0; i < NumberOfImages; i++)
            {
                ToCompare = new Bitmap(ImagesToSearch[i].ToString());
 
                Setlabels("Checking CEDD (3-bit) Similarity", "So Far Results: " + i.ToString());
                CEDDTable_ToCompare = CEDDDescriptor.Apply(ToCompare);
                TotalDeviation = TanimotoClassifier(CEDDTable_ToCompare, CEDDTable_Source); // We are Using Tanimoto in order to Compare Images
 
                DataResults.Rows.Add(ImagesToSearch[i].ToString(), TotalDeviation);
            }
            // Show The Results and Sort them
            dataGrid4.DataSource = DataResults;
            dataGrid4.ReadOnly = false;
            dataGrid4.Columns[1].ReadOnly = true;
            dataGrid4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
            dataGrid4.Columns[1].Width = 20;
            dataGrid4.Columns[0].Width = 160;
 
            int thirdColumn = 1;
            DataGridViewColumn column = dataGrid4.Columns[thirdColumn];
            dataGrid4.Sort(column, (ListSortDirection)0);
            dataGrid4.ReadOnly = true;
            if (dataGrid4.Rows.Count > 1)
            {
                dataGrid4[0, 0].Selected = true;
                PreviewResults();
            }
 
            panel1.Visible = false;
            panel1.Refresh();
pourtant quand je met ce cor dans un button_click il marche parfaitement!!!! svp j'attends votre aide et merci infinement.