void SGMStereo::computeLeftCostImage(const unsigned char* leftGrayscaleImage, const unsigned char* rightGrayscaleImage) { unsigned char* leftSobelImage = reinterpret_cast<unsigned char*>(_mm_malloc(widthStep_*height_*sizeof(unsigned char), 16)); unsigned char* rightSobelImage = reinterpret_cast<unsigned char*>(_mm_malloc(widthStep_*height_*sizeof(unsigned char), 16)); computeCappedSobelImage(leftGrayscaleImage, false, leftSobelImage); computeCappedSobelImage(rightGrayscaleImage, true, rightSobelImage); int* leftCensusImage = reinterpret_cast<int*>(malloc(width_*height_*sizeof(int))); int* rightCensusImage = reinterpret_cast<int*>(malloc(width_*height_*sizeof(int))); computeCensusImage(leftGrayscaleImage, leftCensusImage); computeCensusImage(rightGrayscaleImage, rightCensusImage); unsigned char* leftSobelRow = leftSobelImage; unsigned char* rightSobelRow = rightSobelImage; int* leftCensusRow = leftCensusImage; int* rightCensusRow = rightCensusImage; unsigned short* costImageRow = leftCostImage_; calcTopRowCost(leftSobelRow, leftCensusRow, rightSobelRow, rightCensusRow, costImageRow); costImageRow += width_*disparityTotal_; calcRowCosts(leftSobelRow, leftCensusRow, rightSobelRow, rightCensusRow, costImageRow); _mm_free(leftSobelImage); _mm_free(rightSobelImage); free(leftCensusImage); free(rightCensusImage); }
void SGMStereo::computeLeftCostImage(const unsigned char* leftGrayscaleImage, const unsigned char* rightGrayscaleImage) { unsigned char* leftSobelImage = reinterpret_cast<unsigned char*>(_mm_malloc(widthStep_*height_*sizeof(unsigned char), 16)); unsigned char* rightSobelImage = reinterpret_cast<unsigned char*>(_mm_malloc(widthStep_*height_*sizeof(unsigned char), 16)); //Le filtre de Sobel est un opérateur utilisé en traitement d'image pour la détection de contours. //Il s'agit d'un des opérateurs les plus simples qui donne toutefois des résultats corrects. //Pour faire simple, l'opérateur calcule le gradient de l'intensité de chaque pixel. // Ceci indique la direction de la plus forte variation du clair au sombre, ainsi que le taux de changement dans cette direction. // On connaît alors les points de changement soudain de luminosité, correspondant probablement à des bords, ainsi que l'orientation de ces bords. computeCappedSobelImage(leftGrayscaleImage, false, leftSobelImage); computeCappedSobelImage(rightGrayscaleImage, true, rightSobelImage); int* leftCensusImage = reinterpret_cast<int*>(malloc(width_*height_*sizeof(int))); int* rightCensusImage = reinterpret_cast<int*>(malloc(width_*height_*sizeof(int))); //Census Transform is a form of non-parametric local transform (i.e. relies on the relative ordering of local intensity values, // and not on the intensity values themselves) used in image processing to map the intensity values of the pixels within a square window to a bit string, // thereby capturing the image structure computeCensusImage(leftGrayscaleImage, leftCensusImage); computeCensusImage(rightGrayscaleImage, rightCensusImage); unsigned char* leftSobelRow = leftSobelImage; unsigned char* rightSobelRow = rightSobelImage; int* leftCensusRow = leftCensusImage; int* rightCensusRow = rightCensusImage; unsigned short* costImageRow = leftCostImage_; calcTopRowCost(leftSobelRow, leftCensusRow, rightSobelRow, rightCensusRow, costImageRow); costImageRow += width_*disparityTotal_; calcRowCosts(leftSobelRow, leftCensusRow, rightSobelRow, rightCensusRow, costImageRow); _mm_free(leftSobelImage); _mm_free(rightSobelImage); free(leftCensusImage); free(rightCensusImage); }