You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.2 KiB
C++

#include <cstdio>
#include <vector>
#include <cstdint>
#include <opencv2/opencv.hpp>
#include "hdrplus/utility.h"
void test_downsample_nearest_neighbour( )
{
printf("\n###Test test_box_filter_kxk()###\n");
// Intialize input data
int src_width = 10;
int src_height = 6;
std::vector<uint16_t> src_data( src_width * src_height );
for ( int i = 0; i < src_width * src_height; ++i )
{
src_data[ i ] = i+1;
}
// Create input cv::mat
cv::Mat src_image( src_height, src_width, CV_16U, src_data.data() );
printf("src cv::Mat is \n");
hdrplus::print_cvmat<uint16_t>( src_image );
cv::Mat dst_image = hdrplus::downsample_nearest_neighbour<uint16_t, 2>( src_image );
printf("dst cv::Mat downsample nn 2x2 is \n");
hdrplus::print_cvmat<uint16_t>( dst_image );
dst_image = hdrplus::downsample_nearest_neighbour<uint16_t, 4>( src_image );
printf("dst cv::Mat downsample nn 4x4 is \n");
hdrplus::print_cvmat<uint16_t>( dst_image );
printf("test_downsample_nearest_neighbour finish\n"); fflush(stdout);
}
void test_box_filter_kxk()
{
printf("\n###Test test_box_filter_kxk()###\n");
// Intialize input data
int src_width = 12;
int src_height = 8;
std::vector<uint16_t> src_data( src_width * src_height );
for ( int i = 0; i < src_width * src_height; ++i )
{
src_data[ i ] = i+1;
}
// Create input cv::mat
cv::Mat src_image( src_height, src_width, CV_16U, src_data.data() );
printf("src cv::Mat is \n");
hdrplus::print_cvmat<uint16_t>( src_image );
cv::Mat dst_image = hdrplus::box_filter_kxk<uint16_t, 2>( src_image );
printf("dst cv::Mat 2x2 is \n");
hdrplus::print_cvmat<uint16_t>( dst_image );
dst_image = hdrplus::box_filter_kxk<uint16_t, 4>( src_image );
printf("dst cv::Mat 4x4 is \n");
hdrplus::print_cvmat<uint16_t>( dst_image );
printf("test_box_filter_kxk finish\n"); fflush(stdout);
}
void test_extract_rgb_from_bayer()
{
printf("\n###Test test_extract_rgb_from_bayer()###\n");
// Intialize input data
int bayer_width = 24;
int bayer_height = 16;
std::vector<uint16_t> bayer_data( bayer_width * bayer_height );
for ( int i = 0; i < bayer_width * bayer_height; ++i )
{
bayer_data[ i ] = i+1;
}
// Create input cv::mat
cv::Mat bayer_img = cv::Mat( bayer_height, bayer_width, CV_16U, bayer_data.data() );
cv::Mat red_img, green_img1, green_img2, blue_img;
printf("\nbayer cv::Mat is \n");
hdrplus::print_cvmat<uint16_t>( bayer_img );
hdrplus::extract_rgb_from_bayer<uint16_t>( bayer_img, red_img, green_img1, green_img2, blue_img );
printf("\nRed cv::Mat is \n");
hdrplus::print_cvmat<uint16_t>( red_img );
printf("\nGreen 1 cv::Mat is \n");
hdrplus::print_cvmat<uint16_t>( green_img1 );
printf("\nGreen 2 cv::Mat is \n");
hdrplus::print_cvmat<uint16_t>( green_img2 );
printf("\nBlue cv::Mat is \n");
hdrplus::print_cvmat<uint16_t>( blue_img );
printf("test_extract_rgb_from_bayer finish\n"); fflush(stdout);
}
int main()
{
test_downsample_nearest_neighbour();
test_box_filter_kxk();
test_extract_rgb_from_bayer();
printf("\ntest_utility finish\n");
}