LineHoughTransform::LineHoughTransform(uint8_t *image, int m, int n, uint8_t gradientThreshold, uint8_t voteThreshold) : image_(image), rows_(m), cols_(n), gradientThreshold_(gradientThreshold), voteThreshold_(voteThreshold) { maxDistance_ = static_cast<int>(std::sqrt((rows_-1)*(rows_-1)/4 + cols_*cols_)); accumulator_ = new uint8_t[maxDistance_*91]; // Zero the accumulator. for(int i = 0; i < maxDistance_*91; ++i) accumulator_[i] = 0; edges_ = new uint8_t[rows_*cols_]; // Compute the brightness gradients for the image using the Sobel // operator. sobelEdgeDetect(image_, edges_, rows_, cols_); }
float BlurDetect::calculateBlur(VImage* vim) { QImage* image = vim->getQImage(); assert(image != NULL); // Compute edges + histogram QImage sobelEdges = sobelEdgeDetect(*image); // vector<int> edgeStrengthHist = getEdgeHistogram(sobelEdges); // 15 bins // float rating = calcBlurAmount(edgeStrengthHist); // printHistogram(edgeStrengthHist); vector<double> edgeStrengthList = getEdgeStrengthList(sobelEdges); float rating2 = calcKurtosisRating(edgeStrengthList) * MAX_RATING; // cerr << "Blur result: " << rating2 << endl; return fmin(rating2, MAX_RATING); }