Commit 4b4225d8 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

Jungfrau: improve GainPedCorr accuracy:

* Generate signed images so negative values are kept
* Add 0.5 before converting to integer for better rounding
* Set default GainPedCorr::MapType to Map32
parent cb6eb173
Pipeline #48573 failed with stages
in 12 minutes and 4 seconds
......@@ -37,9 +37,12 @@ inline Data GetMappedData(void *buffer, const FrameDim& frame_dim)
{
Data d;
switch (frame_dim.getImageType()) {
case Bpp8: d.type = Data::UINT8; break;
case Bpp16: d.type = Data::UINT16; break;
case Bpp32: d.type = Data::UINT32; break;
case Bpp8: d.type = Data::UINT8; break;
case Bpp8S: d.type = Data::INT8; break;
case Bpp16: d.type = Data::UINT16; break;
case Bpp16S: d.type = Data::INT16; break;
case Bpp32: d.type = Data::UINT32; break;
case Bpp32S: d.type = Data::INT32; break;
default: throw LIMA_HW_EXC(Error, "Invalid image type");
}
const Size& size = frame_dim.getSize();
......
......@@ -71,8 +71,8 @@ class Jungfrau : public Model
{-3.309899e+0, 18267.3},
{-2.350506e-1, 15250.7},
};
static constexpr Data::TYPE DataType = Data::UINT16;
using Pixel = unsigned short;
static constexpr Data::TYPE DataType = Data::INT16;
using Pixel = short;
};
struct Map32Data {
......@@ -82,8 +82,8 @@ class Jungfrau : public Model
{-3.824832e-2, 15071.6}, // G0 x26
{-2.716186e-3, 15023.8}, // G1 x14
};
static constexpr Data::TYPE DataType = Data::UINT32;
using Pixel = unsigned int;
static constexpr Data::TYPE DataType = Data::INT32;
using Pixel = int;
};
GainPed(Jungfrau *jungfrau);
......@@ -400,7 +400,7 @@ class Jungfrau : public Model
struct MapData {
Data proc_map;
MapData() { proc_map.type = Data::UINT16; }
MapData() { proc_map.type = Data::INT32; }
void updateSize(Size size) {
updateDataSize(proc_map, size);
......
......@@ -128,7 +128,8 @@ void Jungfrau::GainPed::Impl<M>::processFrame(Data& data, Data& proc)
*dst = std::numeric_limits<P>::max() - 0x10;
continue;
}
*dst = (adc - coeffs[gain][1][i]) / coeffs[gain][0][i];
*dst = ((adc - coeffs[gain][1][i]) / coeffs[gain][0][i]
+ 0.5);
DEB_TRACE() << DEB_VAR1(*dst);
}
}
......@@ -140,10 +141,11 @@ void Jungfrau::GainPed::Impl<M>::processFrame(Data& data, Data& proc)
*/
Jungfrau::GainPed::GainPed(Jungfrau *jungfrau)
: m_jungfrau(jungfrau), m_impl(std::in_place_index_t<1>(), jungfrau)
: m_jungfrau(jungfrau),
m_impl(std::in_place_index_t<0>(), jungfrau) // Instantiate Map16
{
DEB_MEMBER_FUNCT();
setMapType(Map16);
setMapType(Map32); // Switch Map16 -> Map32 forces initialization
}
void Jungfrau::GainPed::setMapType(MapType map_type)
......@@ -634,8 +636,8 @@ void Jungfrau::getFrameDim(FrameDim& frame_dim, bool raw)
if (m_img_src == GainPedCorr) {
GainPed::MapType map_type;
m_gain_ped_img_proc->m_gain_ped.getMapType(map_type);
if (map_type == GainPed::Map32)
frame_dim.setImageType(Bpp32);
bool is_map32 = (map_type == GainPed::Map32);
frame_dim.setImageType(is_map32 ? Bpp32S : Bpp16S);
}
DEB_RETURN() << DEB_VAR1(frame_dim);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment