Пример #1
0
QImage mutableSquareImageContainer::scaledImage() const {

  QHash<triC, QImage> colorSquares;
  const QVector<triC>& squareColors = colors();
  const int curDimension = scaledDimension();
  const grid baseImage(image(), originalDimension_);
  QImage squareImage(curDimension, curDimension, QImage::Format_RGB32);
  for (int i = 0, size = squareColors.size(); i < size; ++i) {
    const triC& thisImageColor = squareColors[i];
    squareImage.fill(thisImageColor.qrgb());
    colorSquares[thisImageColor] = squareImage;
  }

  QImage returnImage(scaledSize(), QImage::Format_RGB32);
  QPainter painter(&returnImage);
  for (int yBox = 0; yBox < heightSquareCount_; ++yBox) {
    for (int xBox = 0; xBox < widthSquareCount_; ++xBox) {
      const triC& thisSquareColor =
        baseImage(xBox*originalDimension_, yBox*originalDimension_);
      painter.drawImage(QPoint(xBox*curDimension, yBox*curDimension),
                        colorSquares[thisSquareColor]);

    }
  }
  return returnImage;
}
cv::Mat ImageProcessor::covariance(cv::Mat& targetImage, int window) {
	cv::Mat kernel = cv::Mat::ones( window, window, CV_32F );
	cv::Mat originalImage;
	targetImage.convertTo(originalImage, CV_32F);
	//calculate mean
	cv::Mat mean(originalImage.size(), CV_32F);
	cv::filter2D(originalImage, mean, -1, kernel, cv::Point(-1,-1), 0, cv::BORDER_WRAP);
	//calculate second moment
	cv::Mat squareImage(originalImage.size(), CV_32F);
	cv::pow(originalImage, 2, squareImage);
	cv::Mat varImage(originalImage.size(), CV_32F);
	cv::filter2D(squareImage, varImage, -1, kernel, cv::Point(-1,-1), 0, cv::BORDER_WRAP);
	cv::Mat meanSq(originalImage.size(), CV_32F);
	cv::pow(mean, 2, meanSq);
	cv::Mat variance = varImage - meanSq;

	//rescale
	double lapmin, lapmax;
	cv::minMaxLoc(variance,&lapmin,&lapmax);

	double scale = 255/ std::max(-lapmin,lapmax);
	cv::Mat resultImage;
	cv::convertScaleAbs(variance, resultImage, scale);
	return resultImage;
}
Пример #3
0
/*------------------------------------------------*/
int main(int argc,char **argv)
{
    int i,j,k;
    int length,width,tailleCarre;
    float** MatriceImgR;
    float** MatriceImgI;
    float** MatriceImgM;

    // Generation d'une image carre blanc sur fond noir
    length = 128;
    width = 128;

    printf("Veuillez entrer la taille du carre: ");
    scanf("%d", &tailleCarre);

    MatriceImgR = squareImage(length, width, tailleCarre);

    // Sauvegarde de MatriceImgR sous forme d'image pgm
    SaveImagePgm(NAME_IMG_OUT,MatriceImgR,length,width);

    // Allocation memoire pour la FFT
    MatriceImgI=fmatrix_allocate_2d(length,width);
    MatriceImgM=fmatrix_allocate_2d(length,width);

    // Initialisation a zero de toutes les matrices
    for(i=0;i<length;i++) 
    {
        for(j=0;j<width;j++) 
        {
	        MatriceImgI[i][j]=0.0;
	        MatriceImgM[i][j]=0.0;
        }
    }

    // Decalage de l'image pour obtenir un spectre au centre
    shiftSpatial(MatriceImgR,length,width);
  
    // FFT
    FFTDD(MatriceImgR,MatriceImgI,length,width);

    // Module
    Mod(MatriceImgM,MatriceImgR,MatriceImgI,length,width);

    // Pour visu
    //RecalLog(MatriceImgM,length,width);
    Recal(MatriceImgM,length,width);
    Mult(MatriceImgM,20,length,width);
  
    // Sauvegarde de MatriceImgM sous forme d'image pgm
    SaveImagePgm(NAME_SPC_OUT,MatriceImgM,length,width);

    // Liberation memoire pour les matrices
    free_fmatrix_2d(MatriceImgR);
    free_fmatrix_2d(MatriceImgI); 
    free_fmatrix_2d(MatriceImgM);

    // Retour sans probleme
    printf("\n C'est fini ... \n\n\n");
    return 0; 	 
}