75e401f0e5
Build Packages / Unit tests (push) Successful in 1h31m59s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 8m43s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 10m5s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 9m27s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m56s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 9m24s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 10m27s
Build Packages / build:rpm (rocky8) (push) Successful in 9m20s
Build Packages / build:rpm (rocky9) (push) Successful in 10m50s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 9m54s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m38s
Build Packages / DIALS test (push) Successful in 12m13s
Build Packages / XDS test (durin plugin) (push) Successful in 7m8s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 7m8s
Build Packages / XDS test (neggia plugin) (push) Successful in 7m50s
Build Packages / Generate python client (push) Successful in 16s
Build Packages / Build documentation (push) Successful in 50s
Build Packages / Create release (push) Skipped
This is an UNSTABLE release. It includes many experimental features, as well as many AI generated fixes. We recommend using rc.152 for production use. * jfjoch_broker: Add EXPERIMENTAL pixelrefine mode for image processing * jfjoch_broker: Allow to load user mask from 8-bit and 16-bit TIFF files * jfjoch_broker: Add ROI calculation in non-FPGA workflow * jfjoch_broker: Fixes to TCP image pusher * jfjoch_broker: Remove NUMA bindings * jfjoch_broker: Improvements to indexing * jfjoch_broker: For PSI EIGER, trimming energies are taken from the detector configuration (now compulsory) instead of hardcoded values * jfjoch_writer: Save ROI definitions and the per-pixel ROI bitmap in the master file; azimuthal ROIs support phi (angular) sectors * jfjoch_viewer: Major redesign with dockable panels and saved layouts, plus on-canvas creation/move/resize of box, circle and azimuthal ROIs * jfjoch_viewer: Run jfjoch_process reprocessing jobs from inside the GUI and overlay per-run results Reviewed-on: #63
143 lines
4.3 KiB
C++
143 lines
4.3 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <catch2/catch_all.hpp>
|
|
|
|
#include <fstream>
|
|
|
|
#include "../preview/JFJochTIFF.h"
|
|
#include "../preview/PreviewImage.h"
|
|
#include "../writer/HDF5Objects.h"
|
|
#include "../common/RawToConvertedGeometry.h"
|
|
#include <iostream>
|
|
|
|
TEST_CASE("TIFFTest","[TIFF]") {
|
|
std::vector<uint16_t> values(512*1024);
|
|
CompressedImage image(values, 1024, 512);
|
|
REQUIRE_NOTHROW(WriteTIFFToString(image));
|
|
}
|
|
|
|
TEST_CASE("TIFFTest_Write_Read","[TIFF]") {
|
|
std::vector<uint32_t> values(512*1024);
|
|
for (int i = 0; i < values.size(); i++)
|
|
values[i] = (i * 17 + 2);
|
|
|
|
CompressedImage image(values, 1024, 512);
|
|
|
|
std::string s;
|
|
REQUIRE_NOTHROW(s = WriteTIFFToString(image));
|
|
|
|
std::vector<uint8_t> buffer;
|
|
CompressedImage out = ReadTIFF(s, buffer);
|
|
REQUIRE(out.GetMode() == CompressedImageMode::Uint32);
|
|
REQUIRE(out.GetWidth() == 1024);
|
|
REQUIRE(out.GetHeight() == 512);
|
|
REQUIRE(buffer.size() == values.size() * sizeof(uint32_t));
|
|
REQUIRE(memcmp(values.data(), buffer.data(), buffer.size()) == 0);
|
|
}
|
|
|
|
TEST_CASE("TIFFTest_Write_Read_8bit","[TIFF]") {
|
|
std::vector<uint8_t> values(512*1024);
|
|
for (int i = 0; i < values.size(); i++)
|
|
values[i] = static_cast<uint8_t>(i * 17 + 2);
|
|
|
|
CompressedImage image(values, 1024, 512, CompressedImageMode::Uint8);
|
|
|
|
std::string s;
|
|
REQUIRE_NOTHROW(s = WriteTIFFToString(image));
|
|
|
|
std::vector<uint8_t> buffer;
|
|
CompressedImage out = ReadTIFF(s, buffer);
|
|
REQUIRE(out.GetMode() == CompressedImageMode::Uint8);
|
|
REQUIRE(out.GetWidth() == 1024);
|
|
REQUIRE(out.GetHeight() == 512);
|
|
REQUIRE(buffer == values);
|
|
}
|
|
|
|
TEST_CASE("TIFFTest_Write_Read_16bit","[TIFF]") {
|
|
std::vector<uint16_t> values(512*1024);
|
|
for (int i = 0; i < values.size(); i++)
|
|
values[i] = static_cast<uint16_t>(i * 17 + 2);
|
|
|
|
CompressedImage image(values, 1024, 512);
|
|
|
|
std::string s;
|
|
REQUIRE_NOTHROW(s = WriteTIFFToString(image));
|
|
|
|
std::vector<uint8_t> buffer;
|
|
CompressedImage out = ReadTIFF(s, buffer);
|
|
REQUIRE(out.GetMode() == CompressedImageMode::Uint16);
|
|
REQUIRE(out.GetWidth() == 1024);
|
|
REQUIRE(out.GetHeight() == 512);
|
|
REQUIRE(buffer.size() == values.size() * sizeof(uint16_t));
|
|
REQUIRE(memcmp(values.data(), buffer.data(), buffer.size()) == 0);
|
|
}
|
|
|
|
TEST_CASE("TIFFTest_File","[TIFF]") {
|
|
std::vector<uint16_t> values(512*1024);
|
|
|
|
for (auto &i: values)
|
|
i = 345;
|
|
|
|
CompressedImage image(values, 1024, 512);
|
|
|
|
REQUIRE_NOTHROW(WriteTIFFToFile("test_image.tiff", image));
|
|
}
|
|
|
|
TEST_CASE("TIFFTest_File_signed","[TIFF]") {
|
|
std::vector<int16_t> values(512 * 1024);
|
|
|
|
for (int i = 0; i < values.size(); i++)
|
|
values[i] = static_cast<int16_t>(((i % 2 == 0) ? 1 : -1) * i);
|
|
|
|
CompressedImage image(values, 1024, 512);
|
|
|
|
REQUIRE_NOTHROW(WriteTIFFToFile("test_image_signed.tiff", image));
|
|
}
|
|
|
|
rgb rainbowColor(float t) {
|
|
// Ensure t is in [0,1]
|
|
t = std::max(0.0f, std::min(1.0f, t));
|
|
|
|
// Convert to hue (0 to 6)
|
|
float hue = t * 6.0f;
|
|
|
|
int phase = static_cast<int>(hue);
|
|
float fract = hue - phase;
|
|
|
|
uint8_t p = static_cast<uint8_t>(255 * (1.0f - fract));
|
|
uint8_t q = static_cast<uint8_t>(255 * fract);
|
|
uint8_t full = 255;
|
|
|
|
switch (phase) {
|
|
case 0: return {full, q, 0}; // Red to Yellow
|
|
case 1: return {p, full, 0}; // Yellow to Green
|
|
case 2: return {0, full, q}; // Green to Cyan
|
|
case 3: return {0, p, full}; // Cyan to Blue
|
|
case 4: return {q, 0, full}; // Blue to Magenta
|
|
case 5: return {full, 0, p}; // Magenta to Red
|
|
default: return {full, 0, 0}; // Fallback (red)
|
|
}
|
|
}
|
|
|
|
TEST_CASE("TIFFTest_File_rgb","[TIFF]") {
|
|
std::vector<rgb> values(512 * 1024);
|
|
|
|
for (int i = 0; i < values.size(); i++) {
|
|
float t = static_cast<float>(i % 1024) / (1024 - 1);
|
|
values[i] = rainbowColor(t);
|
|
}
|
|
CompressedImage image(values, 1024, 512);
|
|
|
|
REQUIRE_NOTHROW(WriteTIFFToFile("test_image_rgb.tiff", image));
|
|
}
|
|
|
|
|
|
TEST_CASE("TIFFTest_File_float","[TIFF]") {
|
|
std::vector<float> values(512 * 1024);
|
|
for (int i = 0; i < values.size(); i++)
|
|
values[i] = i / 100.0;
|
|
CompressedImage image(values, 1024, 512);
|
|
REQUIRE_NOTHROW(WriteTIFFToFile("test_image_float.tiff", image));
|
|
}
|