Raw false colour suppression: additional 38% speedup
This commit is contained in:
@@ -11,7 +11,7 @@ set (RTENGINESOURCEFILES colortemp.cc curves.cc flatcurves.cc diagonalcurves.cc
|
||||
dfmanager.cc ffmanager.cc gauss.cc rawimage.cc image8.cc image16.cc imagefloat.cc imagedata.cc imageio.cc improcfun.cc init.cc dcrop.cc
|
||||
loadinitial.cc procparams.cc rawimagesource.cc demosaic_algos.cc shmap.cc simpleprocess.cc refreshmap.cc
|
||||
fast_demo.cc amaze_demosaic_RT.cc CA_correct_RT.cc cfa_linedn_RT.cc green_equil_RT.cc hilite_recon.cc expo_before_b.cc
|
||||
stdimagesource.cc myfile.cc iccjpeg.cc hlmultipliers.cc improccoordinator.cc pipettebuffer.cc coord.cc
|
||||
stdimagesource.cc myfile.cc iccjpeg.cc improccoordinator.cc pipettebuffer.cc coord.cc
|
||||
processingjob.cc rtthumbnail.cc utils.cc labimage.cc slicer.cc cieimage.cc
|
||||
iplab2rgb.cc ipsharpen.cc iptransform.cc ipresize.cc ipvibrance.cc
|
||||
imagedimensions.cc jpeg_memsrc.cc jdatasrc.cc iimage.cc
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
#include "rtengine.h"
|
||||
#include "improcfun.h"
|
||||
#include "curves.h"
|
||||
#include "colorclip.h"
|
||||
#include "gauss.h"
|
||||
#include "bilateral2.h"
|
||||
#include "mytime.h"
|
||||
#include "iccstore.h"
|
||||
#include "impulse_denoise.h"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "cieimage.h"
|
||||
#include "sleef.c"
|
||||
#include "opthelper.h"
|
||||
#include "gauss.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -27,181 +27,63 @@
|
||||
b3 = max(b3,a3);\
|
||||
}
|
||||
|
||||
#define MERGESORT(a1,a2,a3,b1,b2,b3,c1,c2,c3,c4,c5,c6) \
|
||||
{\
|
||||
if (a1<b1) { \
|
||||
c1 = a1; \
|
||||
if (a2<b1) { \
|
||||
c2 = a2; \
|
||||
if (a3<b1) { \
|
||||
c3 = a3; c4 = b1; c5 = b2; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c3 = b1;\
|
||||
if (a3<b2) {\
|
||||
c4 = a3; c5 = b2; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c4 = b2;\
|
||||
if (a3<b3) {\
|
||||
c5 = a3; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c5 = b3; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
c2 = b1;\
|
||||
if (a2<b2) {\
|
||||
c3 = a2;\
|
||||
if (a3<b2) {\
|
||||
c4 = a3; c5 = b2; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c4 = b2;\
|
||||
if (a3<b3) {\
|
||||
c5 = a3; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c5 = b3; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
c3 = b2;\
|
||||
if (a2<b3) {\
|
||||
c4 = a2;\
|
||||
if (a3<b3) {\
|
||||
c5 = a3; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c5 = b3; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
c4 = b3; c5 = a2; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
c1 = b1;\
|
||||
if (a1<b2) {\
|
||||
c2 = a1;\
|
||||
if (a2<b2) {\
|
||||
c3 = a2;\
|
||||
if (a3<b2) {\
|
||||
c4 = a3; c5 = b2; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c4 = b2;\
|
||||
if (a3<b3) {\
|
||||
c5 = a3; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c5 = b3; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
c3 = b2;\
|
||||
if (a2<b3) {\
|
||||
c4 = a2;\
|
||||
if (a3<b3) {\
|
||||
c5 = a3; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c5 = b3; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
c4 = b3; c5 = a2; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
c2 = b2;\
|
||||
if (a1<b3) {\
|
||||
c3 = a1;\
|
||||
if (a2<b3) {\
|
||||
c4 = a2;\
|
||||
if (a3<b3) {\
|
||||
c5 = a3; c6 = b3;\
|
||||
}\
|
||||
else {\
|
||||
c5 = b3; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
c4 = b3; c5 = a2; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
c3 = b3; c4 = a1; c5 = a2; c6 = a3;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
|
||||
#define NETWORKSORT4OF6(s0,s1,s2,s3,s4,s5,d0,d1,d2,d3,d4,d5,temp) \
|
||||
{\
|
||||
d1 = min(s1,s2);\
|
||||
d2 = max(s1,s2);\
|
||||
d0 = min(s0,d2);\
|
||||
d2 = max(s0,d2);\
|
||||
temp = min(d0,d1);\
|
||||
d1 = max(d0,d1);\
|
||||
d0 = temp;\
|
||||
d4 = min(s4,s5);\
|
||||
d5 = max(s4,s5);\
|
||||
temp = min(s3,d5);\
|
||||
d5 = max(s3,d5);\
|
||||
d3 = temp;\
|
||||
temp = min(d3,d4);\
|
||||
d4 = max(d3,d4);\
|
||||
d3 = temp;\
|
||||
d3 = max(d0,d3);\
|
||||
temp = min(d1,d4);\
|
||||
d4 = max(d1,d4);\
|
||||
d1 = temp;\
|
||||
d2 = min(d2,d5);\
|
||||
temp = min(d2,d4);\
|
||||
d4 = max(d2,d4);\
|
||||
d2 = temp;\
|
||||
temp = min(d1,d3);\
|
||||
d3 = max(d1,d3);\
|
||||
d1 = temp;\
|
||||
temp = min(d2,d3);\
|
||||
d3 = max(d2,d3);\
|
||||
d2 = temp;\
|
||||
}
|
||||
|
||||
#define MEDIAN7(a1,a2,a3,b1,b2,b3,b4,median) \
|
||||
{ \
|
||||
if (a1<b1) {\
|
||||
if (a2<b1) {\
|
||||
if (a3<b1) \
|
||||
median = b1; \
|
||||
else {\
|
||||
if (a3<b2) \
|
||||
median = a3;\
|
||||
else \
|
||||
median = b2;\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
if (a2<b2) {\
|
||||
if (a3<b2) \
|
||||
median = a3;\
|
||||
else \
|
||||
median = b2;\
|
||||
}\
|
||||
else {\
|
||||
if (a2<b3) \
|
||||
median = a2;\
|
||||
else \
|
||||
median = b3;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
if (a1<b2) {\
|
||||
if (a2<b2) {\
|
||||
if (a3<b2) \
|
||||
median = a3;\
|
||||
else\
|
||||
median = b2;\
|
||||
}\
|
||||
else {\
|
||||
if (a2<b3)\
|
||||
median = a2;\
|
||||
else\
|
||||
median = b3;\
|
||||
}\
|
||||
}\
|
||||
else {\
|
||||
if (a1<b3) {\
|
||||
if (a2<b3)\
|
||||
median = a2;\
|
||||
else \
|
||||
median = b3; \
|
||||
}\
|
||||
else {\
|
||||
if (a1<b4) \
|
||||
median = a1;\
|
||||
else\
|
||||
median = b4;\
|
||||
} \
|
||||
}\
|
||||
}\
|
||||
#define MEDIAN7(s0,s1,s2,s3,s4,s5,s6,t0,t1,t2,t3,t4,t5,t6,median) \
|
||||
{\
|
||||
t0 = min(s0,s5);\
|
||||
t5 = max(s0,s5);\
|
||||
t3 = max(t0,s3);\
|
||||
t0 = min(t0,s3);\
|
||||
t1 = min(s1,s6);\
|
||||
t6 = max(s1,s6);\
|
||||
t2 = min(s2,s4);\
|
||||
t4 = max(s2,s4);\
|
||||
t1 = max(t0,t1);\
|
||||
median = min(t3,t5);\
|
||||
t5 = max(t3,t5);\
|
||||
t3 = median;\
|
||||
median = min(t2,t6);\
|
||||
t6 = max(t2,t6);\
|
||||
t2 = median;\
|
||||
t3 = max(t2,t3);\
|
||||
t3 = min(t3,t6);\
|
||||
t4 = min(t4,t5);\
|
||||
median = min(t1,t4);\
|
||||
t4 = max(t1,t4);\
|
||||
t1 = median;\
|
||||
t3 = max(t1,t3);\
|
||||
median = min(t3,t4);\
|
||||
}
|
||||
|
||||
|
||||
@@ -3437,12 +3437,13 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, int row
|
||||
SORT3(rbconv_Q[px][1], rbconv_Q[cx][1], rbconv_Q[nx][1], pre2_Q[0], pre2_Q[1], pre2_Q[2]);
|
||||
|
||||
// median I channel
|
||||
float temp[7];
|
||||
for (int j = 1; j < W - 2; j += 2) {
|
||||
SORT3(rbconv_I[px][j + 1], rbconv_I[cx][j + 1], rbconv_I[nx][j + 1], post1_I[0], post1_I[1], post1_I[2]);
|
||||
SORT3(rbconv_I[px][j + 2], rbconv_I[cx][j + 2], rbconv_I[nx][j + 2], post2_I[0], post2_I[1], post2_I[2]);
|
||||
MERGESORT(pre2_I[0], pre2_I[1], pre2_I[2], post1_I[0], post1_I[1], post1_I[2], middle_I[0], middle_I[1], middle_I[2], middle_I[3], middle_I[4], middle_I[5]);
|
||||
MEDIAN7(pre1_I[0], pre1_I[1], pre1_I[2], middle_I[1], middle_I[2], middle_I[3], middle_I[4], rbout_I[cx][j]);
|
||||
MEDIAN7(post2_I[0], post2_I[1], post2_I[2], middle_I[1], middle_I[2], middle_I[3], middle_I[4], rbout_I[cx][j + 1]);
|
||||
NETWORKSORT4OF6(pre2_I[0], pre2_I[1], pre2_I[2], post1_I[0], post1_I[1], post1_I[2], middle_I[0], middle_I[1], middle_I[2], middle_I[3], middle_I[4], middle_I[5], temp[0]);
|
||||
MEDIAN7(pre1_I[0], pre1_I[1], pre1_I[2], middle_I[1], middle_I[2], middle_I[3], middle_I[4], temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], rbout_I[cx][j]);
|
||||
MEDIAN7(post2_I[0], post2_I[1], post2_I[2], middle_I[1], middle_I[2], middle_I[3], middle_I[4], temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], rbout_I[cx][j + 1]);
|
||||
tmp = pre1_I;
|
||||
pre1_I = post1_I;
|
||||
post1_I = tmp;
|
||||
@@ -3456,9 +3457,9 @@ void RawImageSource::processFalseColorCorrectionThread (Imagefloat* im, int row
|
||||
for (int j = 1; j < W - 2; j += 2) {
|
||||
SORT3(rbconv_Q[px][j + 1], rbconv_Q[cx][j + 1], rbconv_Q[nx][j + 1], post1_Q[0], post1_Q[1], post1_Q[2]);
|
||||
SORT3(rbconv_Q[px][j + 2], rbconv_Q[cx][j + 2], rbconv_Q[nx][j + 2], post2_Q[0], post2_Q[1], post2_Q[2]);
|
||||
MERGESORT(pre2_Q[0], pre2_Q[1], pre2_Q[2], post1_Q[0], post1_Q[1], post1_Q[2], middle_Q[0], middle_Q[1], middle_Q[2], middle_Q[3], middle_Q[4], middle_Q[5]);
|
||||
MEDIAN7(pre1_Q[0], pre1_Q[1], pre1_Q[2], middle_Q[1], middle_Q[2], middle_Q[3], middle_Q[4], rbout_Q[cx][j]);
|
||||
MEDIAN7(post2_Q[0], post2_Q[1], post2_Q[2], middle_Q[1], middle_Q[2], middle_Q[3], middle_Q[4], rbout_Q[cx][j + 1]);
|
||||
NETWORKSORT4OF6(pre2_Q[0], pre2_Q[1], pre2_Q[2], post1_Q[0], post1_Q[1], post1_Q[2], middle_Q[0], middle_Q[1], middle_Q[2], middle_Q[3], middle_Q[4], middle_Q[5], temp[0]);
|
||||
MEDIAN7(pre1_Q[0], pre1_Q[1], pre1_Q[2], middle_Q[1], middle_Q[2], middle_Q[3], middle_Q[4], temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], rbout_Q[cx][j]);
|
||||
MEDIAN7(post2_Q[0], post2_Q[1], post2_Q[2], middle_Q[1], middle_Q[2], middle_Q[3], middle_Q[4], temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], rbout_Q[cx][j + 1]);
|
||||
tmp = pre1_Q;
|
||||
pre1_Q = post1_Q;
|
||||
post1_Q = tmp;
|
||||
|
||||
@@ -22,13 +22,15 @@
|
||||
|
||||
#include "rawimagesource.h"
|
||||
|
||||
#include "curves.h"
|
||||
|
||||
namespace rtengine
|
||||
{
|
||||
|
||||
inline void RawImageSource::convert_row_to_YIQ (const float* const r, const float* const g, const float* const b, float* Y, float* I, float* Q, const int W)
|
||||
{
|
||||
#ifdef _OPENMP
|
||||
#pragma omp simd
|
||||
#endif
|
||||
|
||||
for (int j = 0; j < W; j++) {
|
||||
Y[j] = .299f * r[j] + .587f * g[j] + .114f * b[j];
|
||||
I[j] = .596f * r[j] - .275f * g[j] - .321f * b[j];
|
||||
@@ -38,6 +40,10 @@ inline void RawImageSource::convert_row_to_YIQ (const float* const r, const floa
|
||||
|
||||
inline void RawImageSource::convert_row_to_RGB (float* r, float* g, float* b, const float* const Y, const float* const I, const float* const Q, const int W)
|
||||
{
|
||||
#ifdef _OPENMP
|
||||
#pragma omp simd
|
||||
#endif
|
||||
|
||||
for (int j = 1; j < W - 1; j++) {
|
||||
r[j] = Y[j] + 0.956f * I[j] + 0.621f * Q[j];
|
||||
g[j] = Y[j] - 0.272f * I[j] - 0.647f * Q[j];
|
||||
|
||||
Reference in New Issue
Block a user