2024-01-11 13:32:49 -05:00
|
|
|
/**********************************************************************
|
|
|
|
|
* This file is used for testing random stuff without running the
|
|
|
|
|
* whole of SatDump, which comes in handy for debugging individual
|
|
|
|
|
* elements before putting them all together in modules...
|
|
|
|
|
*
|
|
|
|
|
* If you are an user, ignore this file which will not be built by
|
|
|
|
|
* default, and if you're a developper in need of doing stuff here...
|
|
|
|
|
* Go ahead!
|
|
|
|
|
*
|
|
|
|
|
* Don't judge the code you might see in there! :)
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "logger.h"
|
2024-12-30 16:39:35 +01:00
|
|
|
#include "products2/image_product.h"
|
2024-12-12 19:30:09 +01:00
|
|
|
#include "common/image/io.h"
|
2024-12-29 20:13:58 +01:00
|
|
|
#include "common/image/processing.h"
|
2024-12-12 19:30:09 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
#include "products2/image/product_equation.h"
|
2024-12-12 19:30:09 +01:00
|
|
|
|
2024-12-30 16:39:35 +01:00
|
|
|
#include "common/utils.h"
|
|
|
|
|
|
2024-02-23 01:22:22 +01:00
|
|
|
int main(int argc, char *argv[])
|
2024-01-11 13:32:49 -05:00
|
|
|
{
|
|
|
|
|
initLogger();
|
2024-12-12 19:30:09 +01:00
|
|
|
|
2024-12-30 16:39:35 +01:00
|
|
|
satdump::products::ImageProduct products;
|
2024-12-29 20:13:58 +01:00
|
|
|
products.load(argv[1]);
|
2024-12-12 19:30:09 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
#if 0
|
|
|
|
|
image::Image ch1, ch9;
|
|
|
|
|
ch1 = products.get_channel_image("19").image;
|
|
|
|
|
ch9 = products.get_channel_image("10").image;
|
2024-12-12 19:30:09 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
image::Image rgbimg(ch1.depth(), ch1.width(), ch1.height(), 3);
|
2024-12-12 19:30:09 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
satdump::ChannelTransform ch1t = products.get_channel_image("19").ch_transform;
|
|
|
|
|
satdump::ChannelTransform ch9t = products.get_channel_image("10").ch_transform;
|
2024-12-12 19:30:09 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
// ch1t.init_affine(0.95, 1, 0, -1);
|
|
|
|
|
// ch1t.init_affine_slantx(0.93, 1, 2.8, 4,
|
|
|
|
|
// 145.0 / 2.0,
|
|
|
|
|
// 6.0 / (145.0 / 2.0));
|
2024-12-12 19:30:09 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
printf("TYPE IS %f\n", ch1t.getType());
|
2024-12-12 19:30:09 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
image::equalize(ch1, true);
|
|
|
|
|
image::equalize(ch9, true);
|
2024-12-20 20:47:52 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
for (double x = 0; x < rgbimg.width(); x++)
|
|
|
|
|
{
|
|
|
|
|
for (double y = 0; y < rgbimg.height(); y++)
|
|
|
|
|
{
|
|
|
|
|
double ch1_x = x, ch1_y = y;
|
|
|
|
|
double ch9_x = x, ch9_y = y;
|
2024-12-20 20:47:52 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
ch1t.forward(&ch9_x, &ch9_y);
|
|
|
|
|
ch9t.reverse(&ch9_x, &ch9_y);
|
|
|
|
|
// ch9_y += ((ch9_x - (145.0 / 2.0)) / (145.0 / 2.0)) * 11;
|
2024-12-20 20:47:52 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
// printf("%f %f - %f %f\n", ch1_x, ch1_y, ch9_x, ch9_y);
|
2024-12-20 20:47:52 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
rgbimg.set(0, x, y, ch1.get_pixel_bilinear(0, ch1_x, ch1_y));
|
|
|
|
|
rgbimg.set(1, x, y, ch1.get_pixel_bilinear(0, ch1_x, ch1_y));
|
|
|
|
|
if (ch9_x > 0 && ch9_x < ch9.width() && ch9_y > 0 && ch9_y < ch9.height())
|
|
|
|
|
rgbimg.set(2, x, y, ch9.get_pixel_bilinear(0, ch9_x, ch9_y));
|
2024-12-12 19:30:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-12-20 20:47:52 +01:00
|
|
|
|
2024-12-29 20:13:58 +01:00
|
|
|
// image::equalize(rgbimg, true);
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-12-30 16:39:35 +01:00
|
|
|
double start_time = getTime();
|
|
|
|
|
auto rgbimg = satdump::products::generate_equation_product_composite(&products, "ch3, ch2, ch1");
|
|
|
|
|
double end_time = getTime();
|
|
|
|
|
|
|
|
|
|
printf("Time %f\n", end_time - start_time);
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-30 16:39:35 +01:00
|
|
|
// image::equalize(rgbimg, true);
|
2024-12-29 20:13:58 +01:00
|
|
|
|
|
|
|
|
image::save_img(rgbimg, argv[2]);
|
2024-12-12 19:30:09 +01:00
|
|
|
}
|