MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / ClassificationMapper

Class ClassificationMapper

3rd-party/cove/libvectorizer/Vectorizer.cpp:398–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396 * \return New image. */
397
398class ClassificationMapper
399{
400 const std::vector<std::shared_ptr<MapColor>>& sourceImageColors;
401 const KohonenMap& km;
402
403public:
404 ClassificationMapper(const std::vector<std::shared_ptr<MapColor>>& sic, KohonenMap& km)
405 : sourceImageColors(sic)
406 , km(km)
407 {}
408
409 double operator()(const QImage& sourceImage, QImage& outputImage, ProgressObserver& observer) const
410 {
411 auto const width = outputImage.width();
412 auto const height = outputImage.height();
413
414 auto color = std::unique_ptr<MapColor>(
415 dynamic_cast<MapColor*>(sourceImageColors[0]->clone()));
416
417 double quality = 0;
418 for (int y = 0; y < height && !observer.isInterruptionRequested(); y++)
419 {
420 for (int x = 0; x < width; x++)
421 {
422 double distance;
423 color->setRGBTriplet(sourceImage.pixel(x, y));
424 int index = km.findClosest(*color, distance);
425 outputImage.setPixel(x, y, index);
426 quality += color->squares(*sourceImageColors[index]);
427 }
428 observer.setPercentage((100*y) / height);
429 }
430 return quality;
431 }
432
433 using concurrent_processing = HorizontalStripes;
434};
435Q_STATIC_ASSERT((Concurrency::supported<ClassificationMapper>::value));
436
437

Callers 1

getClassifiedImageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected