Hugin trunk 0.1
Loading...
Searching...
No Matches
wxImageCache.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
27#include "wxImageCache.h"
28#include "vigra_ext/utils.h"
29
31{
32 if (e->imageFloat->size().area() > 0)
33 {
34 // for float images we need to apply the mapping as selected by the user
35 // in the preferences
36 const int mapping = wxConfigBase::Get()->Read("/ImageCache/Mapping", HUGIN_IMGCACHE_MAPPING_FLOAT);
37 // find average and variance
38 vigra::RGBToGrayAccessor<vigra::RGBValue<float> > ga;
39 vigra::FindAverageAndVariance<float> mean; // init functor
40 vigra::inspectImage(srcImageRange(*(e->imageFloat), ga), mean);
41 // create temporary image with remapped tone scale
42 vigra::BRGBImage mappedImg(e->imageFloat->size());
43 // scale image to (mean - 3 * std deviation) - (mean + 3 * std deviation),
44 vigra_ext::applyMapping(srcImageRange(*(e->imageFloat)), destImage(mappedImg), std::max(mean.average() - 3 * sqrt(mean.variance()), 1e-6f), mean.average() + 3 * sqrt(mean.variance()), mapping);
45 // convert to wxImage
46 wxImage mappedwxImg(mappedImg.width(), mappedImg.height(), (unsigned char *)mappedImg.data(), true);
47 return mappedwxImg.Copy();
48 }
49 else
50 {
51 ImageCacheRGB8Ptr img = e->get8BitImage();
52 if (img)
53 {
54 return wxImage(img->width(), img->height(), (unsigned char *)img->data(), true);
55 }
56 else
57 {
58 // invalid wxImage
59 return wxImage();
60 };
61 };
62}
63
std::shared_ptr< Entry > EntryPtr
a shared pointer to the entry
Definition ImageCache.h:112
#define HUGIN_IMGCACHE_MAPPING_FLOAT
void applyMapping(vigra::triple< SrcIterator, SrcIterator, SrcAccessor > img, vigra::pair< DestIterator, DestAccessor > dest, T min, T max, int mapping)
Definition utils.h:685
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41
functions to manage ROI's
wxImage imageCacheEntry2wxImage(ImageCache::EntryPtr e)
HuginBase::ImageCache::ImageCacheRGB8Ptr ImageCacheRGB8Ptr