pixelshift: Added support for .badpixels file and raw white point correction

This commit is contained in:
heckflosse
2016-11-29 15:22:33 +01:00
parent 2b09ad6ecc
commit 389d2ebddd
4 changed files with 24 additions and 39 deletions

View File

@@ -44,7 +44,7 @@ namespace rtengine
extern const Settings* settings; extern const Settings* settings;
void RawImageSource::processRawWhitepoint(float expos, float preser) void RawImageSource::processRawWhitepoint(float expos, float preser, array2D<float> &rawData)
{ {
MyTime t1e, t2e; MyTime t1e, t2e;

View File

@@ -68,7 +68,7 @@ float colourDiff(float a, float b, bool adaptive, float stddevFactor, float eper
using namespace std; using namespace std;
using namespace rtengine; using namespace rtengine;
void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool detectMotion, int motion, bool showMotion, bool showOnlyMask, unsigned int frame, unsigned int gridSize, bool adaptive, float stddevFactor, float eperIso, float nreadIso, float prnu, bool checkNonGreenHorizontal, bool checkNonGreenVertical) void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool detectMotion, int motion, bool showMotion, bool showOnlyMask, unsigned int frame, unsigned int gridSize, bool adaptive, float stddevFactor, float eperIso, float nreadIso, float prnu, float rawWpCorrection, bool checkNonGreenHorizontal, bool checkNonGreenVertical)
{ {
BENCHFUN BENCHFUN
@@ -93,7 +93,7 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, bool det
} }
const float scaleGreen = 1.f / scale_mul[1]; const float scaleGreen = 1.f / scale_mul[1];
eperIso *= (100.f / idata->getISOSpeed()); eperIso *= (100.f / (rawWpCorrection * idata->getISOSpeed()));
float eperIsoGreen = eperIso * scaleGreen; float eperIsoGreen = eperIso * scaleGreen;

View File

@@ -916,7 +916,7 @@ void RawImageSource::convertColorSpace(Imagefloat* image, const ColorManagementP
/* interpolateBadPixelsBayer: correct raw pixels looking at the bitmap /* interpolateBadPixelsBayer: correct raw pixels looking at the bitmap
* takes into consideration if there are multiple bad pixels in the neighbourhood * takes into consideration if there are multiple bad pixels in the neighbourhood
*/ */
int RawImageSource::interpolateBadPixelsBayer( PixelsMap &bitmapBads ) int RawImageSource::interpolateBadPixelsBayer( PixelsMap &bitmapBads, array2D<float> &rawData )
{ {
static const float eps = 1.f; static const float eps = 1.f;
int counter = 0; int counter = 0;
@@ -1509,7 +1509,6 @@ int RawImageSource::load (const Glib::ustring &fname, int imageNum, bool batch)
plistener->setProgressStr ("Decoding..."); plistener->setProgressStr ("Decoding...");
plistener->setProgress (0.0); plistener->setProgress (0.0);
} }
StopWatch Stop1("decode");
ri = new RawImage(fname); ri = new RawImage(fname);
int errCode = ri->loadRaw (false, 0, false); int errCode = ri->loadRaw (false, 0, false);
@@ -1548,12 +1547,11 @@ StopWatch Stop1("decode");
if(errCode) { if(errCode) {
return errCode; return errCode;
} }
Stop1.stop();
if(numFrames > 1 ) { // this disables multi frame support for Fuji S5 until I found a solution to handle different dimensions if(numFrames > 1 ) { // this disables multi frame support for Fuji S5 until I found a solution to handle different dimensions
if(riFrames[0]->get_width() != riFrames[1]->get_width() || riFrames[0]->get_height() != riFrames[1]->get_height()) { if(riFrames[0]->get_width() != riFrames[1]->get_width() || riFrames[0]->get_height() != riFrames[1]->get_height()) {
numFrames = 1; numFrames = 1;
} }
pixelShiftColoursScaled = false;
} }
if (plistener) { if (plistener) {
@@ -1667,7 +1665,7 @@ Stop1.stop();
initialGain = 1.0 / min(pre_mul[0], pre_mul[1], pre_mul[2]); initialGain = 1.0 / min(pre_mul[0], pre_mul[1], pre_mul[2]);
}*/ }*/
for(unsigned int i=0;i < numFrames; ++i) { for(unsigned int i = 0;i < numFrames; ++i) {
riFrames[i]->set_prefilters(); riFrames[i]->set_prefilters();
} }
@@ -1918,7 +1916,13 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
if( totBP ) if( totBP )
if ( ri->getSensorType() == ST_BAYER ) { if ( ri->getSensorType() == ST_BAYER ) {
interpolateBadPixelsBayer( *bitmapBads ); if(numFrames == 4) {
for(int i = 0; i < 4; ++i) {
interpolateBadPixelsBayer( *bitmapBads, *rawDataFrames[i] );
}
} else {
interpolateBadPixelsBayer( *bitmapBads, rawData );
}
} else if ( ri->getSensorType() == ST_FUJI_XTRANS ) { } else if ( ri->getSensorType() == ST_FUJI_XTRANS ) {
interpolateBadPixelsXtrans( *bitmapBads ); interpolateBadPixelsXtrans( *bitmapBads );
} else { } else {
@@ -1949,7 +1953,13 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
} }
if ( raw.expos != 1 ) { if ( raw.expos != 1 ) {
processRawWhitepoint(raw.expos, raw.preser); if(numFrames == 4) {
for(int i = 0; i < 4; ++i) {
processRawWhitepoint(raw.expos, raw.preser, *rawDataFrames[i]);
}
} else {
processRawWhitepoint(raw.expos, raw.preser, rawData);
}
} }
if(prepareDenoise && dirpyrdenoiseExpComp == INFINITY) { if(prepareDenoise && dirpyrdenoiseExpComp == INFINITY) {
@@ -1994,7 +2004,7 @@ void RawImageSource::demosaic(const RAWParams &raw)
amaze_demosaic_RT (0, 0, W, H); // for non pixelshift files use amaze if pixelshift is selected. We need it also for motion correction amaze_demosaic_RT (0, 0, W, H); // for non pixelshift files use amaze if pixelshift is selected. We need it also for motion correction
} }
if(numFrames == 4) { if(numFrames == 4) {
pixelshift(0, 0, W, H, raw.bayersensor.pixelshiftMotion > 0, raw.bayersensor.pixelshiftMotion, raw.bayersensor.pixelshiftShowMotion, raw.bayersensor.pixelshiftShowMotionMaskOnly, currFrame, raw.bayersensor.pixelshiftMotionCorrection, raw.bayersensor.pixelShiftAutomatic, raw.bayersensor.pixelShiftStddevFactor, raw.bayersensor.pixelShiftEperIso, raw.bayersensor.pixelShiftNreadIso, raw.bayersensor.pixelShiftPrnu, raw.bayersensor.pixelShiftNonGreenHorizontal, raw.bayersensor.pixelShiftNonGreenVertical); pixelshift(0, 0, W, H, raw.bayersensor.pixelshiftMotion > 0, raw.bayersensor.pixelshiftMotion, raw.bayersensor.pixelshiftShowMotion, raw.bayersensor.pixelshiftShowMotionMaskOnly, currFrame, raw.bayersensor.pixelshiftMotionCorrection, raw.bayersensor.pixelShiftAutomatic, raw.bayersensor.pixelShiftStddevFactor, raw.bayersensor.pixelShiftEperIso, raw.bayersensor.pixelShiftNreadIso, raw.bayersensor.pixelShiftPrnu, raw.expos, raw.bayersensor.pixelShiftNonGreenHorizontal, raw.bayersensor.pixelShiftNonGreenVertical);
} }
} else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::dcb] ) { } else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::dcb] ) {
dcb_demosaic(raw.bayersensor.dcb_iterations, raw.bayersensor.dcb_enhance); dcb_demosaic(raw.bayersensor.dcb_iterations, raw.bayersensor.dcb_enhance);
@@ -3546,28 +3556,6 @@ void RawImageSource::scaleColors(int winx, int winy, int winw, int winh, const R
} }
void RawImageSource::scaleColors_pixelshift(int winx, int winy, int winw, int winh, const RAWParams &raw)
{
BENCHFUN
// scale image colors
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic,64) collapse(2)
#endif
for(int frame = 0; frame < 4; ++frame) {
for (int row = winy; row < winy + winh; row ++)
{
for (int col = winx; col < winx + winw; col++) {
int c = FC(row,col);
float val = (riFrames[frame]->data[row][col] - cblacksom[c]) * scale_mul[c];
riFrames[frame]->data[row][col] = val;
}
}
}
pixelShiftColoursScaled = true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
int RawImageSource::defTransform (int tran) int RawImageSource::defTransform (int tran)

View File

@@ -133,8 +133,6 @@ public:
void copyOriginalPixels(const RAWParams &raw, RawImage *ri, RawImage *riDark, RawImage *riFlatFile, array2D<float> &rawData ); void copyOriginalPixels(const RAWParams &raw, RawImage *ri, RawImage *riDark, RawImage *riFlatFile, array2D<float> &rawData );
void cfaboxblur (RawImage *riFlatFile, float* cfablur, int boxH, int boxW); void cfaboxblur (RawImage *riFlatFile, float* cfablur, int boxH, int boxW);
void scaleColors (int winx, int winy, int winw, int winh, const RAWParams &raw, array2D<float> &rawData); // raw for cblack void scaleColors (int winx, int winy, int winw, int winh, const RAWParams &raw, array2D<float> &rawData); // raw for cblack
void scaleColors_pixelshift(int winx, int winy, int winw, int winh, const RAWParams &raw);
void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw); void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw);
eSensorType getSensorType () const eSensorType getSensorType () const
@@ -207,7 +205,6 @@ public:
ri = riFrames[currFrame]; ri = riFrames[currFrame];
} }
protected: protected:
bool pixelShiftColoursScaled = false;
typedef unsigned short ushort; typedef unsigned short ushort;
void processFalseColorCorrection (Imagefloat* i, const int steps); void processFalseColorCorrection (Imagefloat* i, const int steps);
inline void 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); inline void 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);
@@ -221,9 +218,9 @@ protected:
void CA_correct_RT (const double cared, const double cablue, const double caautostrength, array2D<float> &rawData); void CA_correct_RT (const double cared, const double cablue, const double caautostrength, array2D<float> &rawData);
void ddct8x8s(int isgn, float a[8][8]); void ddct8x8s(int isgn, float a[8][8]);
void processRawWhitepoint (float expos, float preser); // exposure before interpolation void processRawWhitepoint (float expos, float preser, array2D<float> &rawData); // exposure before interpolation
int interpolateBadPixelsBayer( PixelsMap &bitmapBads ); int interpolateBadPixelsBayer( PixelsMap &bitmapBads, array2D<float> &rawData );
int interpolateBadPixelsNColours( PixelsMap &bitmapBads, const int colours ); int interpolateBadPixelsNColours( PixelsMap &bitmapBads, const int colours );
int interpolateBadPixelsXtrans( PixelsMap &bitmapBads ); int interpolateBadPixelsXtrans( PixelsMap &bitmapBads );
int findHotDeadPixels( PixelsMap &bpMap, float thresh, bool findHotPixels, bool findDeadPixels ); int findHotDeadPixels( PixelsMap &bpMap, float thresh, bool findHotPixels, bool findDeadPixels );
@@ -264,7 +261,7 @@ protected:
void xtransborder_interpolate (int border); void xtransborder_interpolate (int border);
void xtrans_interpolate (const int passes, const bool useCieLab); void xtrans_interpolate (const int passes, const bool useCieLab);
void fast_xtrans_interpolate (); void fast_xtrans_interpolate ();
void pixelshift(int winx, int winy, int winw, int winh, bool detectMotion, int motion, bool showMotion, bool showOnlyMask, unsigned int frame, unsigned int gridSize, bool adaptive, float stddevFactor, float eperIso, float nreadIso, float prnu, bool checkNonGreenHorizontal, bool checkNonGreenVertical); void pixelshift(int winx, int winy, int winw, int winh, bool detectMotion, int motion, bool showMotion, bool showOnlyMask, unsigned int frame, unsigned int gridSize, bool adaptive, float stddevFactor, float eperIso, float nreadIso, float prnu, float rawWpCorrection, bool checkNonGreenHorizontal, bool checkNonGreenVertical);
void hflip (Imagefloat* im); void hflip (Imagefloat* im);
void vflip (Imagefloat* im); void vflip (Imagefloat* im);