|
|
|
@ -1,15 +1,27 @@
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
#define _USE_MATH_DEFINES
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#endif
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <opencv2/opencv.hpp> // all opencv header
|
|
|
|
|
#include "hdrplus/finish.h"
|
|
|
|
|
#include "hdrplus/utility.h"
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __ANDROID__
|
|
|
|
|
#define DBG_OUTPUT_ROOT "/sdcard/com.xypower.mpapp/tmp/"
|
|
|
|
|
#else
|
|
|
|
|
#define DBG_OUTPUT_ROOT ""
|
|
|
|
|
#endif
|
|
|
|
|
// #include <type_traits>
|
|
|
|
|
|
|
|
|
|
namespace hdrplus
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cv::Mat convert16bit2_8bit_(cv::Mat ans){
|
|
|
|
|
if(ans.type()==CV_16UC3){
|
|
|
|
|
cv::MatIterator_<cv::Vec3w> it, end;
|
|
|
|
@ -22,7 +34,7 @@ namespace hdrplus
|
|
|
|
|
}
|
|
|
|
|
ans.convertTo(ans, CV_8UC3);
|
|
|
|
|
}else if(ans.type()==CV_16UC1){
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)ans.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)ans.data;
|
|
|
|
|
int end = ans.rows*ans.cols;
|
|
|
|
|
for(int i=0;i<end;i++){
|
|
|
|
|
*(ptr+i) *=(255.0/USHRT_MAX);
|
|
|
|
@ -48,7 +60,7 @@ namespace hdrplus
|
|
|
|
|
|
|
|
|
|
}else if(ans.type()==CV_8UC1){
|
|
|
|
|
ans.convertTo(ans, CV_16UC1);
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)ans.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)ans.data;
|
|
|
|
|
int end = ans.rows*ans.cols;
|
|
|
|
|
for(int i=0;i<end;i++){
|
|
|
|
|
*(ptr+i) *=(65535.0/255.0);
|
|
|
|
@ -129,7 +141,7 @@ namespace hdrplus
|
|
|
|
|
(*it)[2] =uGammaCompress_1pix((*it)[2],threshold,gainMin,gainMax,exponent);
|
|
|
|
|
}
|
|
|
|
|
}else if(m.type()==CV_16UC1){
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)m.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)m.data;
|
|
|
|
|
int end = m.rows*m.cols;
|
|
|
|
|
for(int i=0;i<end;i++){
|
|
|
|
|
*(ptr+i) = uGammaCompress_1pix(*(ptr+i),threshold,gainMin,gainMax,exponent);
|
|
|
|
@ -151,7 +163,7 @@ namespace hdrplus
|
|
|
|
|
(*it)[2] =uGammaDecompress_1pix((*it)[2],threshold,gainMin,gainMax,exponent);
|
|
|
|
|
}
|
|
|
|
|
}else if(m.type()==CV_16UC1){
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)m.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)m.data;
|
|
|
|
|
int end = m.rows*m.cols;
|
|
|
|
|
for(int i=0;i<end;i++){
|
|
|
|
|
*(ptr+i) = uGammaDecompress_1pix(*(ptr+i),threshold,gainMin,gainMax,exponent);
|
|
|
|
@ -172,9 +184,10 @@ namespace hdrplus
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void copy_mat_16U_2(u_int16_t* ptr_A, cv::Mat B){
|
|
|
|
|
// u_int16_t* ptr_A = (u_int16_t*)A.data;
|
|
|
|
|
u_int16_t* ptr_B = (u_int16_t*)B.data;
|
|
|
|
|
void copy_mat_16U_2(uint16_t* ptr_A, cv::Mat B)
|
|
|
|
|
{
|
|
|
|
|
// uint16_t* ptr_A = (uint16_t*)A.data;
|
|
|
|
|
uint16_t* ptr_B = (uint16_t*)B.data;
|
|
|
|
|
for(int r = 0; r < B.rows; r++) {
|
|
|
|
|
for(int c = 0; c < B.cols; c++) {
|
|
|
|
|
*(ptr_A+r*B.cols+c) = *(ptr_B+r*B.cols+c);
|
|
|
|
@ -187,7 +200,7 @@ namespace hdrplus
|
|
|
|
|
int H = img.rows;
|
|
|
|
|
int W = img.cols;
|
|
|
|
|
cv::Mat processedImg = cv::Mat(H,W,CV_16UC1);
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)processedImg.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)processedImg.data;
|
|
|
|
|
|
|
|
|
|
// traverse img
|
|
|
|
|
int idx = 0;
|
|
|
|
@ -204,7 +217,7 @@ namespace hdrplus
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double getMean(cv::Mat img){
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)img.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)img.data;
|
|
|
|
|
int max_idx = img.rows*img.cols*img.channels();
|
|
|
|
|
double sum=0;
|
|
|
|
|
for(int i=0;i<max_idx;i++){
|
|
|
|
@ -216,7 +229,7 @@ namespace hdrplus
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cv::Mat matMultiply_scalar(cv::Mat img,float gain){
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)img.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)img.data;
|
|
|
|
|
int max_idx = img.rows*img.cols*img.channels();
|
|
|
|
|
for(int i=0;i<max_idx;i++){
|
|
|
|
|
double tmp = *(ptr+i)*gain;
|
|
|
|
@ -225,7 +238,7 @@ namespace hdrplus
|
|
|
|
|
}else if(tmp>USHRT_MAX){
|
|
|
|
|
*(ptr+i) = USHRT_MAX;
|
|
|
|
|
}else{
|
|
|
|
|
*(ptr+i)=(u_int16_t)tmp;
|
|
|
|
|
*(ptr+i)=(uint16_t)tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return img;
|
|
|
|
@ -234,7 +247,7 @@ namespace hdrplus
|
|
|
|
|
double getSaturated(cv::Mat img, double threshold){
|
|
|
|
|
threshold *= USHRT_MAX;
|
|
|
|
|
double count=0;
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)img.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)img.data;
|
|
|
|
|
int max_idx = img.rows*img.cols*img.channels();
|
|
|
|
|
for(int i=0;i<max_idx;i++){
|
|
|
|
|
if(*(ptr+i)>threshold){
|
|
|
|
@ -253,7 +266,7 @@ namespace hdrplus
|
|
|
|
|
int H = img.rows;
|
|
|
|
|
int W = img.cols;
|
|
|
|
|
cv::Mat processedImg = cv::Mat(H,W,CV_16UC1);
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)processedImg.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)processedImg.data;
|
|
|
|
|
int idx=0;
|
|
|
|
|
|
|
|
|
|
cv::MatIterator_<cv::Vec3w> it, end;
|
|
|
|
@ -290,8 +303,8 @@ namespace hdrplus
|
|
|
|
|
|
|
|
|
|
cv::Mat applyScaling_(cv::Mat mergedImage, cv::Mat shortGray, cv::Mat fusedGray){
|
|
|
|
|
cv::Mat result = mergedImage.clone();
|
|
|
|
|
u_int16_t* ptr_shortg = (u_int16_t*)shortGray.data;
|
|
|
|
|
u_int16_t* ptr_fusedg = (u_int16_t*)fusedGray.data;
|
|
|
|
|
uint16_t* ptr_shortg = (uint16_t*)shortGray.data;
|
|
|
|
|
uint16_t* ptr_fusedg = (uint16_t*)fusedGray.data;
|
|
|
|
|
int count = 0;
|
|
|
|
|
cv::MatIterator_<cv::Vec3w> it, end;
|
|
|
|
|
for( it = result.begin<cv::Vec3w>(), end = result.end<cv::Vec3w>(); it != end; ++it)
|
|
|
|
@ -384,7 +397,7 @@ namespace hdrplus
|
|
|
|
|
std::cout<<"--- Scale channels"<<std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
u_int16_t enhanceContrast_1pix(u_int16_t pix_val,double gain){
|
|
|
|
|
uint16_t enhanceContrast_1pix(uint16_t pix_val,double gain){
|
|
|
|
|
double x = pix_val;
|
|
|
|
|
x/=USHRT_MAX;
|
|
|
|
|
x = x - gain*sin(2*M_PI*x);
|
|
|
|
@ -393,13 +406,13 @@ namespace hdrplus
|
|
|
|
|
}else if(x>1){
|
|
|
|
|
x = 1;
|
|
|
|
|
}
|
|
|
|
|
u_int16_t result = x*USHRT_MAX;
|
|
|
|
|
uint16_t result = x*USHRT_MAX;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cv::Mat enhanceContrast(cv::Mat image, Options options){
|
|
|
|
|
if(options.gtmContrast>=0 && options.gtmContrast<=1){
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)image.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)image.data;
|
|
|
|
|
int end = image.rows*image.cols*image.channels();
|
|
|
|
|
for(int idx = 0;idx<end;idx++){
|
|
|
|
|
*(ptr+idx) = enhanceContrast_1pix(*(ptr+idx),options.gtmContrast);
|
|
|
|
@ -415,9 +428,9 @@ namespace hdrplus
|
|
|
|
|
int end_y = Y.rows*Y.cols*Y.channels();
|
|
|
|
|
cv::Mat result = cv::Mat(X.rows,X.cols,X.type());
|
|
|
|
|
if(end_x==end_y){
|
|
|
|
|
u_int16_t* ptr_x = (u_int16_t*)X.data;
|
|
|
|
|
u_int16_t* ptr_y = (u_int16_t*)Y.data;
|
|
|
|
|
u_int16_t* ptr_r = (u_int16_t*)result.data;
|
|
|
|
|
uint16_t* ptr_x = (uint16_t*)X.data;
|
|
|
|
|
uint16_t* ptr_y = (uint16_t*)Y.data;
|
|
|
|
|
uint16_t* ptr_r = (uint16_t*)result.data;
|
|
|
|
|
for(int i=0;i<end_x;i++){
|
|
|
|
|
if(*(ptr_x+i)<*(ptr_y+i)){
|
|
|
|
|
*(ptr_r+i) = *(ptr_y+i) - *(ptr_x+i);
|
|
|
|
@ -438,14 +451,14 @@ namespace hdrplus
|
|
|
|
|
// create result mat
|
|
|
|
|
cv::Mat result = cv::Mat(image.rows,image.cols,image.type());
|
|
|
|
|
// initialize iteraters
|
|
|
|
|
u_int16_t* ptr_r = (u_int16_t*)result.data;
|
|
|
|
|
u_int16_t* ptr_img = (u_int16_t*)image.data;
|
|
|
|
|
u_int16_t* ptr_blur0 = (u_int16_t*)blur0.data;
|
|
|
|
|
u_int16_t* ptr_low0 = (u_int16_t*)low0.data;
|
|
|
|
|
u_int16_t* ptr_blur1 = (u_int16_t*)blur1.data;
|
|
|
|
|
u_int16_t* ptr_low1 = (u_int16_t*)low1.data;
|
|
|
|
|
u_int16_t* ptr_blur2 = (u_int16_t*)blur2.data;
|
|
|
|
|
u_int16_t* ptr_low2 = (u_int16_t*)low2.data;
|
|
|
|
|
uint16_t* ptr_r = (uint16_t*)result.data;
|
|
|
|
|
uint16_t* ptr_img = (uint16_t*)image.data;
|
|
|
|
|
uint16_t* ptr_blur0 = (uint16_t*)blur0.data;
|
|
|
|
|
uint16_t* ptr_low0 = (uint16_t*)low0.data;
|
|
|
|
|
uint16_t* ptr_blur1 = (uint16_t*)blur1.data;
|
|
|
|
|
uint16_t* ptr_low1 = (uint16_t*)low1.data;
|
|
|
|
|
uint16_t* ptr_blur2 = (uint16_t*)blur2.data;
|
|
|
|
|
uint16_t* ptr_low2 = (uint16_t*)low2.data;
|
|
|
|
|
int n_channels = image.channels();
|
|
|
|
|
int end = image.rows*image.cols*n_channels;
|
|
|
|
|
// traverse Image
|
|
|
|
@ -464,7 +477,7 @@ namespace hdrplus
|
|
|
|
|
r = (r0+r1+r2)/3.0;
|
|
|
|
|
if(r<0) r=0;
|
|
|
|
|
if(r>USHRT_MAX) r = USHRT_MAX;
|
|
|
|
|
*(ptr_r+idx) = (u_int16_t)r;
|
|
|
|
|
*(ptr_r+idx) = (uint16_t)r;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
@ -496,9 +509,9 @@ namespace hdrplus
|
|
|
|
|
return sharpImage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void copy_mat_16U_3(u_int16_t* ptr_A, cv::Mat B){
|
|
|
|
|
// u_int16_t* ptr_A = (u_int16_t*)A.data;
|
|
|
|
|
u_int16_t* ptr_B = (u_int16_t*)B.data;
|
|
|
|
|
void copy_mat_16U_3(uint16_t* ptr_A, cv::Mat B){
|
|
|
|
|
// uint16_t* ptr_A = (uint16_t*)A.data;
|
|
|
|
|
uint16_t* ptr_B = (uint16_t*)B.data;
|
|
|
|
|
int H = B.rows;
|
|
|
|
|
int W = B.cols;
|
|
|
|
|
int end = H*W;
|
|
|
|
@ -507,9 +520,9 @@ namespace hdrplus
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// void copy_mat_16U_3(u_int16_t* ptr_A, cv::Mat B){
|
|
|
|
|
// // u_int16_t* ptr_A = (u_int16_t*)A.data;
|
|
|
|
|
// u_int16_t* ptr_B = (u_int16_t*)B.data;
|
|
|
|
|
// void copy_mat_16U_3(uint16_t* ptr_A, cv::Mat B){
|
|
|
|
|
// // uint16_t* ptr_A = (uint16_t*)A.data;
|
|
|
|
|
// uint16_t* ptr_B = (uint16_t*)B.data;
|
|
|
|
|
// for(int r = 0; r < B.rows; r++) {
|
|
|
|
|
// for(int c = 0; c < B.cols; c++) {
|
|
|
|
|
// *(ptr_A+r*B.cols+c) = *(ptr_B+r*B.cols+c);
|
|
|
|
@ -518,6 +531,7 @@ namespace hdrplus
|
|
|
|
|
// }
|
|
|
|
|
cv::Mat processMergedMat(cv::Mat mergedImg, int opencv_type){
|
|
|
|
|
cv::Mat m;
|
|
|
|
|
#if 0
|
|
|
|
|
uint16_t* ptr = (uint16_t*)mergedImg.data;
|
|
|
|
|
for(int r = 0; r < mergedImg.rows; r++) {
|
|
|
|
|
std::vector<int> dvals;
|
|
|
|
@ -528,17 +542,18 @@ namespace hdrplus
|
|
|
|
|
cv::transpose(mline, mline);
|
|
|
|
|
m.push_back(mline);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
int ch = CV_MAT_CN(opencv_type);
|
|
|
|
|
|
|
|
|
|
m = mergedImg.clone();
|
|
|
|
|
m = m.reshape(ch);
|
|
|
|
|
m.convertTo(m, opencv_type);
|
|
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void show20_20(cv::Mat m){
|
|
|
|
|
u_int16_t* ptr = (u_int16_t*)m.data;
|
|
|
|
|
uint16_t* ptr = (uint16_t*)m.data;
|
|
|
|
|
for(int i=0;i<20;i++){
|
|
|
|
|
for(int j=0;j<20;j++){
|
|
|
|
|
std::cout<<*(ptr+i*m.cols+j)<<", ";
|
|
|
|
@ -561,29 +576,30 @@ namespace hdrplus
|
|
|
|
|
|
|
|
|
|
// save merged Image value
|
|
|
|
|
#ifndef HDRPLUS_NO_DETAILED_OUTPUT
|
|
|
|
|
writeCSV("merged.csv",burst_images.merged_bayer_image);
|
|
|
|
|
writeCSV(DBG_OUTPUT_ROOT "merged.csv",burst_images.merged_bayer_image);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
this->refIdx = burst_images.reference_image_idx;
|
|
|
|
|
// this->burstPath = burstPath;
|
|
|
|
|
// std::cout<<"processMerged:"<<std::endl;
|
|
|
|
|
// show20_20(mergedB);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef HDRPLUS_NO_DETAILED_OUTPUT
|
|
|
|
|
this->mergedBayer = loadFromCSV(DBG_OUTPUT_ROOT "merged.csv", CV_16UC1);
|
|
|
|
|
// this->mergedBayer = processMergedMat(mergedB,CV_16UC1);//loadFromCSV("merged.csv", CV_16UC1);
|
|
|
|
|
// std::cout<<"processMerged:"<<std::endl;
|
|
|
|
|
// show20_20(this->mergedBayer);
|
|
|
|
|
this->mergedBayer = loadFromCSV("merged.csv", CV_16UC1);
|
|
|
|
|
// this->mergedBayer = loadFromCSV(DBG_OUTPUT_ROOT "merged.csv", CV_16UC1);
|
|
|
|
|
// this->mergedBayer = processMergedMat(burst_images.merged_bayer_image, CV_16UC1);
|
|
|
|
|
#else
|
|
|
|
|
this->mergedBayer = processMergedMat(burst_images.merged_bayer_image, CV_16UC1);
|
|
|
|
|
// this->mergedBayer = loadFromCSV(DBG_OUTPUT_ROOT "merged.csv", CV_16UC1);
|
|
|
|
|
this->mergedBayer = processMergedMat(burst_images.merged_bayer_image, CV_16UC1);
|
|
|
|
|
// std::cout<<"processMerged:"<<std::endl;
|
|
|
|
|
#endif
|
|
|
|
|
// std::cout<<"csv:"<<std::endl;
|
|
|
|
|
// show20_20(this->mergedBayer);
|
|
|
|
|
// load_rawPathList(burstPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// read in ref img
|
|
|
|
|
// bayer_image* ref = new bayer_image(rawPathList[refIdx]);
|
|
|
|
|
bayer_image* ref = new bayer_image(burst_images.bayer_images[burst_images.reference_image_idx]);
|
|
|
|
@ -598,7 +614,7 @@ namespace hdrplus
|
|
|
|
|
cv::Mat outputImg = convert16bit2_8bit_(processedRefImage.clone());
|
|
|
|
|
cv::cvtColor(outputImg, outputImg, cv::COLOR_RGB2BGR);
|
|
|
|
|
// cv::imshow("test",processedImage);
|
|
|
|
|
cv::imwrite("processedRef.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "processedRef.jpg", outputImg);
|
|
|
|
|
// cv::waitKey(0);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
@ -610,7 +626,7 @@ namespace hdrplus
|
|
|
|
|
cv::Mat outputImg = gammasRGB(processedRefImage.clone(),true);
|
|
|
|
|
outputImg = convert16bit2_8bit_(outputImg);
|
|
|
|
|
cv::cvtColor(outputImg, outputImg, cv::COLOR_RGB2BGR);
|
|
|
|
|
cv::imwrite("processedRefGamma.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "processedRefGamma.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -627,7 +643,7 @@ namespace hdrplus
|
|
|
|
|
std::cout<<"writing Merged img ..."<<std::endl;
|
|
|
|
|
cv::Mat outputImg = convert16bit2_8bit_(processedMerge.clone());
|
|
|
|
|
cv::cvtColor(outputImg, outputImg, cv::COLOR_RGB2BGR);
|
|
|
|
|
cv::imwrite("mergedImg.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "mergedImg.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -638,7 +654,7 @@ namespace hdrplus
|
|
|
|
|
cv::Mat outputImg = gammasRGB(processedMerge.clone(),true);
|
|
|
|
|
outputImg = convert16bit2_8bit_(outputImg);
|
|
|
|
|
cv::cvtColor(outputImg, outputImg, cv::COLOR_RGB2BGR);
|
|
|
|
|
cv::imwrite("mergedImgGamma.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "mergedImgGamma.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -654,7 +670,7 @@ namespace hdrplus
|
|
|
|
|
if(params.flags["writeShortExposure"]){
|
|
|
|
|
std::cout<<"writing ShortExposure img ..."<<std::endl;
|
|
|
|
|
cv::Mat outputImg = convert16bit2_8bit_(shortExposure);
|
|
|
|
|
cv::imwrite("shortg.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "shortg.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -662,7 +678,7 @@ namespace hdrplus
|
|
|
|
|
if(params.flags["writeLongExposure"]){
|
|
|
|
|
std::cout<<"writing LongExposure img ..."<<std::endl;
|
|
|
|
|
cv::Mat outputImg = convert16bit2_8bit_(longExposure);
|
|
|
|
|
cv::imwrite("longg.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "longg.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -670,7 +686,7 @@ namespace hdrplus
|
|
|
|
|
if(params.flags["writeFusedExposure"]){
|
|
|
|
|
std::cout<<"writing FusedExposure img ..."<<std::endl;
|
|
|
|
|
cv::Mat outputImg = convert16bit2_8bit_(fusedExposure);
|
|
|
|
|
cv::imwrite("fusedg.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "fusedg.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -679,7 +695,7 @@ namespace hdrplus
|
|
|
|
|
std::cout<<"writing LTMImage ..."<<std::endl;
|
|
|
|
|
cv::Mat outputImg = convert16bit2_8bit_(processedMerge.clone());
|
|
|
|
|
cv::cvtColor(outputImg, outputImg, cv::COLOR_RGB2BGR);
|
|
|
|
|
cv::imwrite("ltmGain.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "ltmGain.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -689,7 +705,7 @@ namespace hdrplus
|
|
|
|
|
cv::Mat outputImg = gammasRGB(processedMerge.clone(),true);
|
|
|
|
|
outputImg = convert16bit2_8bit_(outputImg);
|
|
|
|
|
cv::cvtColor(outputImg, outputImg, cv::COLOR_RGB2BGR);
|
|
|
|
|
cv::imwrite("ltmGain_gamma.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "ltmGain_gamma.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -710,7 +726,7 @@ namespace hdrplus
|
|
|
|
|
cv::Mat outputImg = convert16bit2_8bit_(processedMerge.clone());
|
|
|
|
|
cv::cvtColor(outputImg, outputImg, cv::COLOR_RGB2BGR);
|
|
|
|
|
|
|
|
|
|
cv::imwrite("GTM_gamma.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "GTM_gamma.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -723,7 +739,7 @@ namespace hdrplus
|
|
|
|
|
cv::Mat outputImg = convert16bit2_8bit_(processedImage.clone());
|
|
|
|
|
cv::cvtColor(outputImg, outputImg, cv::COLOR_RGB2BGR);
|
|
|
|
|
|
|
|
|
|
cv::imwrite("FinalImage.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "FinalImage.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -745,15 +761,15 @@ namespace hdrplus
|
|
|
|
|
cv::Mat outputImg = convert16bit2_8bit_(processedRefImage.clone());
|
|
|
|
|
cv::cvtColor(outputImg, outputImg, cv::COLOR_RGB2BGR);
|
|
|
|
|
|
|
|
|
|
cv::imwrite("FinalReference.jpg", outputImg);
|
|
|
|
|
cv::imwrite(DBG_OUTPUT_ROOT "FinalReference.jpg", outputImg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
// End of finishing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void finish::copy_mat_16U(cv::Mat& A, cv::Mat B){
|
|
|
|
|
u_int16_t* ptr_A = (u_int16_t*)A.data;
|
|
|
|
|
u_int16_t* ptr_B = (u_int16_t*)B.data;
|
|
|
|
|
uint16_t* ptr_A = (uint16_t*)A.data;
|
|
|
|
|
uint16_t* ptr_B = (uint16_t*)B.data;
|
|
|
|
|
for(int r = 0; r < A.rows; r++) {
|
|
|
|
|
for(int c = 0; c < A.cols; c++) {
|
|
|
|
|
*(ptr_A+r*A.cols+c) = *(ptr_B+r*B.cols+c);
|
|
|
|
@ -764,8 +780,8 @@ namespace hdrplus
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void finish::copy_rawImg2libraw(std::shared_ptr<LibRaw>& libraw_ptr, cv::Mat B){
|
|
|
|
|
u_int16_t* ptr_A = (u_int16_t*)libraw_ptr->imgdata.rawdata.raw_image;
|
|
|
|
|
u_int16_t* ptr_B = (u_int16_t*)B.data;
|
|
|
|
|
uint16_t* ptr_A = (uint16_t*)libraw_ptr->imgdata.rawdata.raw_image;
|
|
|
|
|
uint16_t* ptr_B = (uint16_t*)B.data;
|
|
|
|
|
for(int r = 0; r < B.rows; r++) {
|
|
|
|
|
for(int c = 0; c < B.cols; c++) {
|
|
|
|
|
*(ptr_A+r*B.cols+c) = *(ptr_B+r*B.cols+c);
|
|
|
|
|