NeuralNetInferenceClient: Handle case of unsigned data

This commit is contained in:
2025-06-29 13:07:40 +02:00
parent 39faa49d86
commit d6dbe53955

View File

@@ -242,13 +242,22 @@ std::optional<float> NeuralNetInferenceClient::Inference(const DiffractionExperi
switch (experiment.GetByteDepthImage()) {
case 1:
v = PrepareInternal(experiment, (int8_t *) image, q);
if (experiment.IsPixelSigned())
v = PrepareInternal(experiment, (int8_t *) image, q);
else
v = PrepareInternal(experiment, (uint8_t *) image, q);
break;
case 2:
v = PrepareInternal(experiment, (int16_t *) image, q);
if (experiment.IsPixelSigned())
v = PrepareInternal(experiment, (int16_t *) image, q);
else
v = PrepareInternal(experiment, (uint16_t *) image, q);
break;
case 4:
v = PrepareInternal(experiment, (int32_t *) image, q);
if (experiment.IsPixelSigned())
v = PrepareInternal(experiment, (int32_t *) image, q);
else
v = PrepareInternal(experiment, (uint32_t *) image, q);
break;
default:
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Bit depth not supported");
@@ -259,7 +268,8 @@ std::optional<float> NeuralNetInferenceClient::Inference(const DiffractionExperi
return {};
float two_theta = atanf(
((2.0f * experiment.GetPixelSize_mm() / experiment.GetDetectorDistance_mm()) * resp.value()));
((2.0f * GetMaxPoolFactor(experiment) * experiment.GetPixelSize_mm()
/ experiment.GetDetectorDistance_mm()) * resp.value()));
float stheta = sinf(two_theta * 0.5f);
float resolution = experiment.GetWavelength_A() / (2.0f * stheta);
return resolution;