Author: post
Date: 2009-06-28 01:27:37 +0200 (Sun, 28 Jun 2009)
New Revision: 2519
Modified:
trunk/plugins/denoise/denoise.c
trunk/plugins/denoise/denoiseinterface.h
trunk/plugins/denoise/fftdenoiser.cpp
trunk/plugins/denoise/fftdenoiseryuv.cpp
trunk/plugins/denoise/fftdenoiseryuv.h
trunk/plugins/denoise/floatplanarimage-x86.cpp
trunk/plugins/denoise/floatplanarimage.cpp
trunk/plugins/denoise/floatplanarimage.h
Log:
Denoise: Make RGB to YUV coefficients adjustable via interface. Fixed image
conversion assembler not being compiled on 32 bits systems.
Modified: trunk/plugins/denoise/denoise.c
===================================================================
--- trunk/plugins/denoise/denoise.c 2009-06-27 17:51:58 UTC (rev 2518)
+++ trunk/plugins/denoise/denoise.c 2009-06-27 23:27:37 UTC (rev 2519)
@@ -38,6 +38,7 @@
gint sharpen;
gint denoise_luma;
gint denoise_chroma;
+ gfloat warmth, tint;
};
struct _RSDenoiseClass {
@@ -50,12 +51,14 @@
PROP_0,
PROP_SHARPEN,
PROP_DENOISE_LUMA,
- PROP_DENOISE_CHROMA
+ PROP_DENOISE_CHROMA,
+ PROP_SETTINGS
};
static void get_property (GObject *object, guint property_id, GValue *value,
GParamSpec *pspec);
static void set_property (GObject *object, guint property_id, const GValue
*value, GParamSpec *pspec);
static RS_IMAGE16 *get_image(RSFilter *filter, RS_FILTER_PARAM *param);
+static void settings_changed(RSSettings *settings, RSSettingsMask mask,
RSDenoise *denoise);
static RSFilterClass *rs_denoise_parent_class = NULL;
@@ -101,11 +104,42 @@
G_PARAM_READWRITE)
);
+ g_object_class_install_property(object_class,
+ PROP_SETTINGS, g_param_spec_object(
+ "settings", "Settings", "Settings to render from",
+ RS_TYPE_SETTINGS, G_PARAM_READWRITE)
+ );
+
filter_class->name = "FFT denoise filter";
filter_class->get_image = get_image;
}
static void
+settings_changed(RSSettings *settings, RSSettingsMask mask, RSDenoise *denoise)
+{
+ gboolean changed = FALSE;
+
+ if ((mask & MASK_WB) || (mask & MASK_CHANNELMIXER))
+ {
+ const gfloat warmth;
+ const gfloat tint;
+
+ g_object_get(settings,
+ "warmth", &warmth,
+ "tint", &tint,
+ NULL );
+ if (ABS(warmth-denoise->warmth) > 0.01 ||
ABS(tint-denoise->tint) > 0.01) {
+ changed = TRUE;
+ }
+ denoise->warmth = warmth;
+ denoise->tint = tint;
+ }
+
+ if (changed)
+ rs_filter_changed(RS_FILTER(denoise),
RS_FILTER_CHANGED_PIXELDATA);
+}
+
+static void
rs_denoise_init(RSDenoise *denoise)
{
denoise->info.processMode = PROCESS_YUV;
@@ -113,6 +147,8 @@
denoise->sharpen = 0;
denoise->denoise_luma = 0;
denoise->denoise_chroma = 0;
+ denoise->warmth = 0.23f; // Default values
+ denoise->tint = 0.07f;
/* FIXME: Remember to destroy */
}
@@ -132,6 +168,9 @@
case PROP_DENOISE_CHROMA:
g_value_set_int(value, denoise->denoise_chroma);
break;
+ case PROP_SETTINGS:
+ printf("Settings\n");
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id,
pspec);
}
@@ -142,6 +181,7 @@
{
RSDenoise *denoise = RS_DENOISE(object);
RSFilter *filter = RS_FILTER(denoise);
+ RSSettings *settings;
switch (property_id)
{
@@ -166,6 +206,12 @@
rs_filter_changed(filter,
RS_FILTER_CHANGED_PIXELDATA);
}
break;
+ case PROP_SETTINGS:
+ settings = g_value_get_object(value);
+ g_signal_connect(settings, "settings-changed",
G_CALLBACK(settings_changed), denoise);
+ settings_changed(settings, MASK_ALL, denoise);
+ printf("Settings\n");
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id,
pspec);
}
@@ -200,9 +246,11 @@
denoise->info.sharpenCutoffLuma = 0.3f;
denoise->info.beta = 1.0;
denoise->info.sharpenChroma = 0.0f;
-
denoise->info.sharpenMinSigmaLuma = denoise->info.sigmaLuma + 2.0;
+ denoise->info.redCorrection = (1.0+denoise->warmth)*(2.0-denoise->tint);
+ denoise->info.blueCorrection =
(1.0-denoise->warmth)*(2.0-denoise->tint);
+
GTimer *gt = g_timer_new();
denoiseImage(&denoise->info);
gfloat time = g_timer_elapsed(gt, NULL);
Modified: trunk/plugins/denoise/denoiseinterface.h
===================================================================
--- trunk/plugins/denoise/denoiseinterface.h 2009-06-27 17:51:58 UTC (rev
2518)
+++ trunk/plugins/denoise/denoiseinterface.h 2009-06-27 23:27:37 UTC (rev
2519)
@@ -52,6 +52,8 @@
float sharpenMinSigmaChroma; // Minimum limit (approximate noise margin)
for sharpening stage (default=4.0)
float sharpenMaxSigmaChroma; // Maximum limit (approximate oversharping
margin) for sharpening stage (default=20.0)
+ float redCorrection; // Red coefficient, multiplid to R in YUV
conversion. (default: 1.0)
+ float blueCorrection; // Blue coefficient, multiplid to R in YUV
conversion. (default: 1.0)
void* _this; // Do not modify this value.
} FFTDenoiseInfo;
Modified: trunk/plugins/denoise/fftdenoiser.cpp
===================================================================
--- trunk/plugins/denoise/fftdenoiser.cpp 2009-06-27 17:51:58 UTC (rev
2518)
+++ trunk/plugins/denoise/fftdenoiser.cpp 2009-06-27 23:27:37 UTC (rev
2519)
@@ -206,6 +206,8 @@
info->sharpenMinSigmaChroma = 4.0f;
info->sharpenMaxSigmaLuma = 20.0f;
info->sharpenMaxSigmaChroma = 20.0f;
+ info->redCorrection = 1.0f;
+ info->blueCorrection = 1.0f;
}
void denoiseImage(FFTDenoiseInfo* info) {
Modified: trunk/plugins/denoise/fftdenoiseryuv.cpp
===================================================================
--- trunk/plugins/denoise/fftdenoiseryuv.cpp 2009-06-27 17:51:58 UTC (rev
2518)
+++ trunk/plugins/denoise/fftdenoiseryuv.cpp 2009-06-27 23:27:37 UTC (rev
2519)
@@ -34,6 +34,9 @@
img.ox = FFT_BLOCK_OVERLAP;
img.oy = FFT_BLOCK_OVERLAP;
+ img.redCorrection = redCorrection;
+ img.blueCorrection = blueCorrection;
+
if ((image->w < FFT_BLOCK_SIZE) || (image->h < FFT_BLOCK_SIZE))
return; // Image too small to denoise
@@ -85,4 +88,7 @@
sharpenCutoffChroma = info->sharpenCutoffChroma*SIGMA_FACTOR;
sharpenMinSigmaChroma = info->sharpenMinSigmaChroma*SIGMA_FACTOR;
sharpenMaxSigmaChroma = info->sharpenMaxSigmaChroma*SIGMA_FACTOR;
+ redCorrection = info->redCorrection;
+ blueCorrection = info->blueCorrection;
+
}
\ No newline at end of file
Modified: trunk/plugins/denoise/fftdenoiseryuv.h
===================================================================
--- trunk/plugins/denoise/fftdenoiseryuv.h 2009-06-27 17:51:58 UTC (rev
2518)
+++ trunk/plugins/denoise/fftdenoiseryuv.h 2009-06-27 23:27:37 UTC (rev
2519)
@@ -14,8 +14,8 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
-*/
-
+*/
+
#ifndef fftdenoiseryuv_h__
#define fftdenoiseryuv_h__
@@ -28,12 +28,14 @@
FFTDenoiserYUV();
virtual ~FFTDenoiserYUV(void);
virtual void denoiseImage(RS_IMAGE16* image);
- virtual void setParameters( FFTDenoiseInfo *info);
+ virtual void setParameters( FFTDenoiseInfo *info);
float sigmaLuma;
float sigmaChroma;
float sharpenChroma;
float sharpenCutoffChroma;
float sharpenMinSigmaChroma;
float sharpenMaxSigmaChroma;
+ float redCorrection;
+ float blueCorrection;
};
#endif // fftdenoiseryuv_h__
Modified: trunk/plugins/denoise/floatplanarimage-x86.cpp
===================================================================
--- trunk/plugins/denoise/floatplanarimage-x86.cpp 2009-06-27 17:51:58 UTC
(rev 2518)
+++ trunk/plugins/denoise/floatplanarimage-x86.cpp 2009-06-27 23:27:37 UTC
(rev 2519)
@@ -17,6 +17,8 @@
*/
#include "floatplanarimage.h"
+#if defined (__i386__) || defined (__x86_64__)
+
#if defined (__x86_64__)
// Only 64 bits, and only if pixelsize is 4
@@ -24,9 +26,9 @@
{
RS_IMAGE16* image = j->rs;
float* temp = p[0]->data;
- temp[0] = (0.299* WB_R_CORR); temp[4] = 0.587; temp[8] = (0.114 *
WB_B_CORR); temp[3] = 0.0f;
- temp[1] = (-0.169* WB_R_CORR); temp[5] = -0.331; temp[9] = (0.499 *
WB_B_CORR); temp[7] = 0.0f;
- temp[2] = (0.499* WB_R_CORR); temp[6] = -0.418; temp[10] =(-0.0813 *
WB_B_CORR); temp[11] = 0.0f;
+ temp[0] = (0.299 * redCorrection); temp[4] = 0.587; temp[8] = (0.114 *
blueCorrection); temp[3] = 0.0f;
+ temp[1] = (-0.169 * redCorrection); temp[5] = -0.331; temp[9] = (0.499 *
blueCorrection); temp[7] = 0.0f;
+ temp[2] = (0.499 * redCorrection); temp[6] = -0.418; temp[10] =(-0.0813 *
blueCorrection); temp[11] = 0.0f;
asm volatile
(
@@ -113,6 +115,7 @@
asm volatile ( "emms\n" );
}
+#endif // defined (__x86_64__)
#if defined (__x86_64__)
@@ -125,8 +128,8 @@
temp[i+4] = -0.714f; // Cr to g
temp[i+8] = -0.344f; // Cb to g
temp[i+12] = 1.772f; // Cb to b
- temp[i+16] = (1.0f/WB_R_CORR); // Red correction
- temp[i+20] = (1.0f/WB_B_CORR); // Blue correction
+ temp[i+16] = (1.0f/redCorrection); // Red correction
+ temp[i+20] = (1.0f/blueCorrection); // Blue correction
temp[i+24] = 65535.0f; // Saturation
}
@@ -216,8 +219,8 @@
temp[i+4] = -0.714f; // Cr to g
temp[i+8] = -0.344f; // Cb to g
temp[i+12] = 1.772f; // Cb to b
- temp[i+16] = (1.0f/WB_R_CORR); // Red correction
- temp[i+20] = (1.0f/WB_B_CORR); // Blue correction
+ temp[i+16] = (1.0f/redCorrection); // Red correction
+ temp[i+20] = (1.0f/blueCorrection); // Blue correction
temp[i+24] = 65535.0f; // Saturation
}
@@ -300,8 +303,8 @@
temp[i+4] = -0.714f; // Cr to g
temp[i+8] = -0.344f; // Cb to g
temp[i+12] = 1.772f; // Cb to b
- temp[i+16] = (1.0f/WB_R_CORR); // Red correction
- temp[i+20] = (1.0f/WB_B_CORR); // Blue correction
+ temp[i+16] = (1.0f/redCorrection); // Red correction
+ temp[i+20] = (1.0f/blueCorrection); // Blue correction
temp[i+24] = 65535.0f; // Saturation
}
int* itemp = (int*)(&temp[28]);
Modified: trunk/plugins/denoise/floatplanarimage.cpp
===================================================================
--- trunk/plugins/denoise/floatplanarimage.cpp 2009-06-27 17:51:58 UTC (rev
2518)
+++ trunk/plugins/denoise/floatplanarimage.cpp 2009-06-27 23:27:37 UTC (rev
2519)
@@ -23,6 +23,8 @@
FloatPlanarImage::FloatPlanarImage(void) {
p = 0;
+ redCorrection = blueCorrection = 1.0f;
+
}
FloatPlanarImage::FloatPlanarImage( const FloatPlanarImage &img )
@@ -36,6 +38,9 @@
bh = img.bh;
ox = img.ox;
oy = img.oy;
+
+ redCorrection = img.redCorrection;
+ blueCorrection = img.blueCorrection;
}
FloatPlanarImage::~FloatPlanarImage(void) {
@@ -158,6 +163,13 @@
return unpackInterleavedYUV_SSE(j);
#endif
+ gfloat r1 = 0.299 * redCorrection;
+ gfloat r2 = -0.169 * redCorrection;
+ gfloat r3 = 0.499 * redCorrection;
+ gfloat b1 = 0.114 * blueCorrection;
+ gfloat b2 = 0.499 * blueCorrection;
+ gfloat b3 = -0.0813 * blueCorrection;
+
for (int y = j->start_y; y < j->end_y; y++ ) {
const gushort* pix = GET_PIXEL(image,0,y);
gfloat *Y = p[0]->getAt(ox, y+oy);
@@ -167,9 +179,9 @@
float r = shortToFloat[(*pix)];
float g = shortToFloat[(*(pix+1))];
float b = shortToFloat[(*(pix+2))];
- *Y++ = r * 0.299 * WB_R_CORR + g * 0.587 + b * 0.114 * WB_B_CORR ;
- *Cb++ = r * -0.169 * WB_R_CORR + g * -0.331 + b * 0.499 * WB_B_CORR;
- *Cr++ = r * 0.499 * WB_R_CORR + g * -0.418 + b * -0.0813 * WB_B_CORR;
+ *Y++ = r * r1 + g * 0.587 + b * b1 ;
+ *Cb++ = r * r2 + g * -0.331 + b * b2;
+ *Cr++ = r * r3 + g * -0.418 + b * b3;
pix += image->pixelsize;
}
}
@@ -215,15 +227,17 @@
return;
}
#endif
+ gfloat r_factor = (1.0f/redCorrection);
+ gfloat b_factor = (1.0f/blueCorrection);
for (int y = j->start_y; y < j->end_y; y++ ) {
gfloat *Y = p[0]->getAt(ox, y+oy);
gfloat *Cb = p[1]->getAt(ox, y+oy);
gfloat *Cr = p[2]->getAt(ox, y+oy);
gushort* out = GET_PIXEL(image,0,y);
for (int x=0; x<image->w; x++) {
- float fr = (Y[x] + 1.402 * Cr[x]) * (1.0f/WB_R_CORR);
+ float fr = (Y[x] + 1.402 * Cr[x]) * r_factor;
float fg = Y[x] - 0.344 * Cb[x] - 0.714 * Cr[x];
- float fb = (Y[x] + 1.772 * Cb[x]) * (1.0f/WB_B_CORR);
+ float fb = (Y[x] + 1.772 * Cb[x]) * b_factor;
int r = (int)(fr*fr);
int g = (int)(fg*fg);
int b = (int)(fb*fb);
Modified: trunk/plugins/denoise/floatplanarimage.h
===================================================================
--- trunk/plugins/denoise/floatplanarimage.h 2009-06-27 17:51:58 UTC (rev
2518)
+++ trunk/plugins/denoise/floatplanarimage.h 2009-06-27 23:27:37 UTC (rev
2519)
@@ -45,10 +45,10 @@
JobQueue* getJobs(FloatPlanarImage &outImg);
void unpackInterleavedYUV( const ImgConvertJob* j );
#if defined (__i386__) || defined (__x86_64__)
- void unpackInterleavedYUV_SSE( const ImgConvertJob* j );
void packInterleavedYUV_SSE2( const ImgConvertJob* j);
#endif
#if defined (__x86_64__)
+ void unpackInterleavedYUV_SSE( const ImgConvertJob* j );
void packInterleavedYUV_SSE4( const ImgConvertJob* j);
#endif
void packInterleavedYUV( const ImgConvertJob* j);
@@ -60,6 +60,10 @@
int bh; // Block height
int ox; // Overlap pixels
int oy; // Overlap pixels
+
+ float redCorrection;
+ float blueCorrection;
+
static void initConvTable();
static float shortToFloat[65536];
};
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit