Charger une image et appliquer un filtre
Bonjour, je suis débutant en c++ builder et je souhaiterai établir un programme qui charge une image puis lui appliquée un filtre par le biais d'un produit de convolution. j'ai pu réalisé les premières étapes mes au niveau du produit de convolution sa bloque, en plus je reçois des messages d'erreurs E2015 au niveau de "Image1[][]" qui dit: "Ambiguity between 'TComponent::operator IInterfaceComponentReference*()' and 'Tcomponent::operator IInterface*()'".
Je vous écrit le code c++ et j'espère que quelqu'un d'entre vous puisse m'aider à résoudre le problème. merci d'avance
cordialement
Le code c++
Code:
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
| //---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::OuvrirClick(TObject *Sender)
{
this->OpenPictureDialog1->Execute();
Image1->Picture->LoadFromFile(this->OpenPictureDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LectureClick(TObject *Sender)
{
int l,c;
int** image1;
//Lecture
l=Image1->Height;
c=Image1->Width;
image1=new int*[l];
for (int x=0 ; x<=l; x++)
image1[x]=new int [c];
//niveau gris
for (int x=0 ; x<=l; x++){
for (int y=0 ; y<=c; y++){
int r,v,b,g;
r=GetRValue(this->Image1->Canvas->Pixels [x][y]);
v=GetGValue(this->Image1->Canvas->Pixels [x][y]);
b=GetBValue(this->Image1->Canvas->Pixels [x][y]);
g=div(r+v+b,3).quot;
image1[x][y]=g;
}
}
//Affichage
this->StringGrid1->ColCount=c;
this->StringGrid1->RowCount=l;
for (int x=0 ; x<=l; x++){
for (int y=0 ; y<=c; y++){
this->StringGrid1->Cells [x][y]=image1[x][y];
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FiltreClick(TObject *Sender)
{
int** filt;
//Lecture
filt=new int*[3];
for (int i=0 ; i<=3; i++)
filt[i]=new int [3];
//Affichage
this->StringGrid2->ColCount=3;
this->StringGrid2->RowCount=3;
for (int i=0 ; i<=3; i++){
for (int j=0 ; j<=3; j++){
this->StringGrid2->Cells [0][0]=1;
this->StringGrid2->Cells [0][1]=0;
this->StringGrid2->Cells [0][2]=-1;
this->StringGrid2->Cells [1][0]=1;
this->StringGrid2->Cells [1][1]=0;
this->StringGrid2->Cells [1][2]=-1;
this->StringGrid2->Cells [2][0]=1;
this->StringGrid2->Cells [2][1]=0;
this->StringGrid2->Cells [2][2]=-1;
}
}
for (int i=0 ; i<=3; i++){
for (int j=0 ; j<=3; j++){
this->StringGrid2->Cells [i][j] = filt[i][j];
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ConvolutionClick(TObject *Sender)
{
int h,w,t1,t2;
int** conv,filt;
h=Image1->Height;
w=Image1->Width;
conv=new int*[h];
for (int x=0 ; x<=h; x++)
conv[x]=new int [w];
// Produit de convolution
for (int x=1 ; x<=h-1; x++){
for (int y=1 ; y<=w-1; y++){
t1=filt[0][0]*Image1[x-1][y-1]+filt[0][1]*Image1[x-1][y]+filt[0][2]*Image1[x-1][y+1]+filt[1][0]*Image1[x][y-1]+filt[1][1]*Image1[x][y]+filt[1][2]*Image1[x][y+1]+filt[2][0]*Image1[x+1][y-1]+filt[2][1]*Image1[x+1][y]+filt[2][2]*Image1[x+1][y+1];
t2=div(t1,9).quot;
conv[x][y]=t2;
}
}
// affichage
for (int x=0 ; x<=h; x++){
for (int y=0 ; y<=w; y++){
this->Image2->Canvas->Pixels [x][y];
}
}
}
//--------------------------------------------------------------------------- |