QVis RegionService::createHistogram(const MatSet& matSet, QLP region) { QVis histograms(9); for(int i=0; i<9; i++) { int BITE = 256; QVi channelHistogram(matSet.bgr().elemSize1()*BITE, 0); histograms[i] = channelHistogram; } for(Point point : region) { histograms.value(0)[B(matSet.bgr(), point.x, point.y)]++; histograms.value(1)[G(matSet.bgr(), point.x, point.y)]++; histograms.value(2)[R(matSet.bgr(), point.x, point.y)]++; histograms.value(3)[B(matSet.hsv(), point.x, point.y)]++; histograms.value(4)[G(matSet.hsv(), point.x, point.y)]++; histograms.value(5)[R(matSet.hsv(), point.x, point.y)]++; histograms.value(6)[B(matSet.ycrcb(), point.x, point.y)]++; histograms.value(7)[G(matSet.ycrcb(), point.x, point.y)]++; histograms.value(8)[R(matSet.ycrcb(), point.x, point.y)]++; } return histograms; }
void actionCollect(const std::string &filename, enum CollectingMode mode, bool mwaChannels, size_t flaggedTimesteps, const std::set<size_t> &flaggedAntennae) { StatisticsCollection statisticsCollection; HistogramCollection histogramCollection; actionCollect(filename, mode, statisticsCollection, histogramCollection, mwaChannels, flaggedTimesteps, flaggedAntennae); switch(mode) { case CollectDefault: { std::cout << "Writing quality tables..." << std::endl; QualityTablesFormatter qualityData(filename); statisticsCollection.Save(qualityData); } break; case CollectHistograms: { std::cout << "Writing histogram tables..." << std::endl; HistogramTablesFormatter histograms(filename); histogramCollection.Save(histograms); } break; } std::cout << "Done.\n"; }
void VideoAsset::process() { HistogramHSV histograms(player); while(!player->isFinished()) { histograms.iterate(); frame2Timestamp.push_back(std::make_pair(player->getFrameNum(),player->getCurrentTime())); player->update(); std::cout << player->getFrameNum() << " " << player->getCurrentTime() << std::endl; } ShotDetector shotdetector(&histograms); shotdetector.process(); boundaries = shotdetector.boundaries; flashes = shotdetector.flashes; this->histograms = histograms.histograms; this->rgbMeans = histograms.rgbMeans; writeHistograms(); writeTimetable(); writeShotBoundaries(); writeMeans(); hasTimetable = true; hasShotBoundaries = true; hasHistograms = true; hasMeans = true; isReady = true; }
TEST (ROPSFeature, FeatureExtraction) { float support_radius = 0.0285f; unsigned int number_of_partition_bins = 5; unsigned int number_of_rotations = 3; pcl::search::KdTree<pcl::PointXYZ>::Ptr search_method (new pcl::search::KdTree<pcl::PointXYZ>); search_method->setInputCloud (cloud); pcl::ROPSEstimation <pcl::PointXYZ, pcl::Histogram <135> > feature_estimator; feature_estimator.setSearchMethod (search_method); feature_estimator.setSearchSurface (cloud); feature_estimator.setInputCloud (cloud); feature_estimator.setIndices (indices); feature_estimator.setTriangles (triangles); feature_estimator.setRadiusSearch (support_radius); feature_estimator.setNumberOfPartitionBins (number_of_partition_bins); feature_estimator.setNumberOfRotations (number_of_rotations); feature_estimator.setSupportRadius (support_radius); pcl::PointCloud<pcl::Histogram <135> >::Ptr histograms (new pcl::PointCloud <pcl::Histogram <135> > ()); feature_estimator.compute (*histograms); EXPECT_NE (0, histograms->points.size ()); }
vector<int> calcHist(float* v, int n, int bins) { vector<int> histograms(bins, 0); float MM = *max_element(v, v+n); float mm = *min_element(v, v + n); float seg = (MM - mm) * 1.0/ bins; for(int pp = 0; pp < n; pp ++) { histograms[int((v[pp] - mm)/seg)] ++; } return histograms; }
Vector< Histogram<double> > TestingAnalysis::calculate_error_data_histograms(const unsigned& bins_number) const { const Vector< Matrix<double> > error_data = calculate_error_data(); const unsigned outputs_number = error_data.size(); Vector< Histogram<double> > histograms(outputs_number); for(unsigned i = 0; i < outputs_number; i++) { histograms[i] = error_data[i].arrange_column(0).calculate_histogram(bins_number); } return(histograms); }
void RFIGuiController::PlotLogLogDist() { if(IsImageLoaded()) { TimeFrequencyData activeData = ActiveData(); HistogramCollection histograms(activeData.PolarisationCount()); for(unsigned p=0;p!=activeData.PolarisationCount();++p) { TimeFrequencyData *polData = activeData.CreateTFDataFromPolarisationIndex(p); Image2DCPtr image = polData->GetSingleImage(); Mask2DCPtr mask = Mask2D::CreateCopy(polData->GetSingleMask()); histograms.Add(0, 1, p, image, mask); } _rfiGuiWindow.ShowHistogram(histograms); } }
void VideoThumbnailer::generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame) { vector<VideoFrame> videoFrames(SMART_FRAME_ATTEMPTS); vector<Histogram<int> > histograms(SMART_FRAME_ATTEMPTS); for (int i = 0; i < SMART_FRAME_ATTEMPTS; ++i) { movieDecoder.decodeVideoFrame(); movieDecoder.getScaledVideoFrame(m_ThumbnailSize, m_MaintainAspectRatio, videoFrames[i]); generateHistogram(videoFrames[i], histograms[i]); } int bestFrame = getBestThumbnailIndex(videoFrames, histograms); Q_ASSERT(bestFrame != -1); videoFrame = videoFrames[bestFrame]; }
TEST (ROPSFeature, InvalidParameters) { float support_radius = 0.0285f; unsigned int number_of_partition_bins = 5; unsigned int number_of_rotations = 3; pcl::search::KdTree<pcl::PointXYZ>::Ptr search_method (new pcl::search::KdTree<pcl::PointXYZ>); search_method->setInputCloud (cloud); pcl::ROPSEstimation <pcl::PointXYZ, pcl::Histogram <135> > feature_estimator; feature_estimator.setSearchMethod (search_method); feature_estimator.setSearchSurface (cloud); feature_estimator.setInputCloud (cloud); feature_estimator.setIndices (indices); feature_estimator.setTriangles (triangles); feature_estimator.setRadiusSearch (support_radius); feature_estimator.setNumberOfPartitionBins (number_of_partition_bins); feature_estimator.setNumberOfRotations (number_of_rotations); feature_estimator.setSupportRadius (support_radius); pcl::PointCloud<pcl::Histogram <135> >::Ptr histograms (new pcl::PointCloud <pcl::Histogram <135> > ()); support_radius = -support_radius; feature_estimator.setSupportRadius (support_radius); support_radius = feature_estimator.getSupportRadius (); EXPECT_LT (0.0f, support_radius); number_of_partition_bins = 0; feature_estimator.setNumberOfPartitionBins (number_of_partition_bins); number_of_partition_bins = feature_estimator.getNumberOfPartitionBins (); EXPECT_LT (0, number_of_partition_bins); number_of_rotations = 0; feature_estimator.setNumberOfRotations (number_of_rotations); number_of_rotations = feature_estimator.getNumberOfRotations (); EXPECT_LT (0, number_of_rotations); std::vector <pcl::Vertices> empty_triangles; feature_estimator.setTriangles (empty_triangles); feature_estimator.compute (*histograms); EXPECT_EQ (0, histograms->points.size ()); }
void VectorTest::test_calculate_total_frequencies(void) { message += "test_calculate_total_frequencies\n"; Vector<double> v1; Vector<double> v2; Vector<double> v3; Vector<size_t> total_frequencies; Vector < Histogram<double> > histograms(2); // Test v1.set(0.0, 1, 9.0); v2.set(5); v2[0] = 0.0; v2[1] = 2.0; v2[2] = 6.0; v2[3] = 6.0; v2[4] = 9.0; v3.set(2); v3[0] = 8.0; v3[1] = 6.0; histograms[0] = v1.calculate_histogram(10); histograms[1] = v2.calculate_histogram(10); total_frequencies = v3.calculate_total_frequencies(histograms); assert_true(total_frequencies[0] == 1, LOG); assert_true(total_frequencies[1] == 2, LOG); }