Fixed scaling for int32
This commit is contained in:
@@ -115,16 +115,11 @@ void ImageWidget::setImage(std::shared_ptr<RawImage> image, int index)
|
|||||||
|
|
||||||
m_unit_scale[0] = 1.0f;
|
m_unit_scale[0] = 1.0f;
|
||||||
m_unit_scale[1] = 0.0f;
|
m_unit_scale[1] = 0.0f;
|
||||||
auto &stats = image->imageStats();
|
if(image->type() == RawImage::FLOAT32)
|
||||||
if(image->type() == RawImage::FLOAT32 || image->type() == RawImage::FLOAT64)
|
|
||||||
{
|
{
|
||||||
float min = *std::min_element(stats.m_min, stats.m_min + 4);
|
auto unitScaling = image->unitScale();
|
||||||
float max = *std::max_element(stats.m_max, stats.m_max + 4);
|
m_unit_scale[0] = unitScaling.first;
|
||||||
if(min < 0.0f || max > 1.0f)
|
m_unit_scale[1] = unitScaling.second;
|
||||||
{
|
|
||||||
m_unit_scale[0] = 1.0f / (max - min);
|
|
||||||
m_unit_scale[1] = min * m_unit_scale[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_debayerTex)
|
if(m_debayerTex)
|
||||||
|
|||||||
@@ -567,6 +567,23 @@ void RawImage::downscaleTo(uint32_t size)
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair<float, float> RawImage::unitScale() const
|
||||||
|
{
|
||||||
|
float min = *std::min_element(m_stats.m_min, m_stats.m_min + 4);
|
||||||
|
float max = *std::max_element(m_stats.m_max, m_stats.m_max + 4);
|
||||||
|
|
||||||
|
if(m_origType == UINT32)
|
||||||
|
{
|
||||||
|
min /= (float)UINT32_MAX;
|
||||||
|
max /= (float)UINT32_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(min < 0.0f || max > 1.0f)
|
||||||
|
return {1.0f / (max - min), min / (max - min)};
|
||||||
|
else
|
||||||
|
return {1.0f, 0.0f};
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<RawImage> RawImage::fromPlanar(const RawImage &img)
|
std::shared_ptr<RawImage> RawImage::fromPlanar(const RawImage &img)
|
||||||
{
|
{
|
||||||
return RawImage::fromPlanar(img.data(), img.width(), img.height(), img.channels(), img.type());
|
return RawImage::fromPlanar(img.data(), img.width(), img.height(), img.channels(), img.type());
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ public:
|
|||||||
float thumbAspect() const;
|
float thumbAspect() const;
|
||||||
bool pixel(int x, int y, double &r, double &g, double &b) const;
|
bool pixel(int x, int y, double &r, double &g, double &b) const;
|
||||||
void downscaleTo(uint32_t size);
|
void downscaleTo(uint32_t size);
|
||||||
|
std::pair<float, float> unitScale() const;
|
||||||
|
|
||||||
static std::shared_ptr<RawImage> fromPlanar(const RawImage &img);
|
static std::shared_ptr<RawImage> fromPlanar(const RawImage &img);
|
||||||
static std::shared_ptr<RawImage> fromPlanar(const void *pixels, uint32_t w, uint32_t h, uint32_t ch, DataType type);
|
static std::shared_ptr<RawImage> fromPlanar(const void *pixels, uint32_t w, uint32_t h, uint32_t ch, DataType type);
|
||||||
|
|||||||
Reference in New Issue
Block a user