Bonjour,
Je suis entrain de programmer un filtre sous OpenCV. Pour cela, j'utilise la fonction suivante :
(Ne vous inquiétez pas pour VAL qui n'est pas défini, j'ai juste simplifié mon code pour en venir à l'essentiel, VAL est un float)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 IplImage * filter(IplImage * a){ int width = a->width; int height = a->height; IplImage * b = cvCreateImage(cvSize(height,width),IPL_DEPTH_32F,1); int astep = a->widthStep; int bstep = b->widthStep; int achannels = a->nChannels; int bchannels = b->nChannels; float * bdata = (float*) b->imageData; float * adata = (float*) a->imageData; for(int i=0;i<height;i++)for(int j=0;j<width;j++) bdata[i*bstep+j*bchannels] = adata[i*astep+j*achannels]*VAL; return b; }
Mon problème est que je n'accède visiblement pas aux éléments correctement, car j'ai une erreur de segmentation au cours de la boucle appliquant le filtre. Mon image "a" est elle aussi définie en float (IPL_DEPTH_32F)
Pourriez-vous me dire ce que je ne fais pas correctement?
Merci d'avance![]()
Partager