Image Demosaicking with Contour Stencils
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
dmcswl1.h File Reference

Contour stencils weighted L1 demosaicing. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int CSWL1Demosaic (float *Image, int Width, int Height, int RedX, int RedY, float Alpha, float Epsilon, float Sigma, float Tol, int MaxIter, int ShowEnergy)
 Contour stencils weighted L1 demosaicing. More...
 
int DisplayContours (const float *Image, int Width, int Height, int RedX, int RedY, const char *OutputFile)
 Display orientations estimated by mosaiced contour stencils. More...
 
void FitMosaicedStencils (int *Stencil, const float *Input, int Width, int Height, int RedX, int RedY)
 Estimate the contour orientations of a mosaiced image. More...
 

Detailed Description

Contour stencils weighted L1 demosaicing.

Author
Pascal Getreuer getre.nosp@m.uer@.nosp@m.gmail.nosp@m..com

Copyright (c) 2010-2011, Pascal Getreuer All rights reserved.

This program is free software: you can use, modify and/or redistribute it under the terms of the simplified BSD License. You should have received a copy of this license along this program. If not, see http://www.opensource.org/licenses/bsd-license.html.

Definition in file dmcswl1.h.

Function Documentation

int CSWL1Demosaic ( float *  Image,
int  Width,
int  Height,
int  RedX,
int  RedY,
float  Alpha,
float  Epsilon,
float  Sigma,
float  Tol,
int  MaxIter,
int  ShowEnergy 
)

Contour stencils weighted L1 demosaicing.

Parameters
Imagethe input RGB image in planar row-major order
Width,Heightthe image dimensions
RedX,RedYthe coordinates of the upper-leftmost red pixel
Alphaweight on the chromatic term
Epsilonedge weight for weak links in the graph
Sigmagraph filtering parameter
Tolstopping tolerance
MaxItermaximum number of iterations
ShowEnergyif nonzero, display the energy value after each iteration
Returns
1 on success, 0 on failure

This is the main computation routine for contour stencils demosaicing. It solves the minimization

\[ \left\{ \begin{aligned} \operatorname*{arg\,min}_{d,u} & \sum_m \Bigl(\sum_n \bigl(w_{m,n} d^L_{m,n} \bigr)^2\Bigr)^{1/2} + \alpha \sum_m \Bigl(\sum_n \Bigl(w_{m,n} \sqrt{(d^{C1}_{m,n})^2 + (d^{C2}_{m,n})^2} \,\Bigr)^2\Bigr)^{1/2} \\ \text{subject to} \; & d_{m,n} = C(u_m - u_n), \; m,n\in\mathbb{Z}^2, \\ & u_m^{k} = f_m, \; m\in\Omega^k, k\in\{R,G,B\}, \end{aligned}\right. \]

by Bregman iteration. This is done by alternatingly solving the D-subproblem with DShrink and the U-subproblem with UGaussSeidel.

Definition at line 750 of file dmcswl1.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int DisplayContours ( const float *  Image,
int  Width,
int  Height,
int  RedX,
int  RedY,
const char *  OutputFile 
)

Display orientations estimated by mosaiced contour stencils.

Parameters
Imagethe input RGB image in planar row-major order
Width,Heightthe image dimensions
RedX,RedYthe coordinates of the upper-leftmost red pixel
OutputFileEPS file to write
Returns
1 on success, 0 on failure
Warning
For larger images (e.g., over 300x300), the output EPS file is very large. Some measures are taken for efficient encoding, but compression is not performed.

This routine writes an EPS file of Image superimposed with the orientations detected by mosaiced contour stencils at each pixel. This function is called when running the command line program with the -s option.

For visualization purposes, it is recommended to pass an image that has full color information rather than a mosaiced image (i.e., use the original image or a demosaiced image). The estimated contour orientations are the same regardless of whether the input is mosaiced.

Using the Ghostscript program, the EPS output (say, "contours.eps") can be converted to PDF as

gs -dSAFER -q -P- -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH \
-sDEVICE=pdfwrite -sOutputFile=contours.pdf -c .setpdfwrite \
-f contours.eps

Distiller commands are included within the EPS to preserve the bounding box. PDF conversion applies (lossless) deflate compression to the image data, which significantly decreases the file size.

Definition at line 59 of file displaycontours.c.

void FitMosaicedStencils ( int *  Stencil,
const float *  Input,
int  Width,
int  Height,
int  RedX,
int  RedY 
)

Estimate the contour orientations of a mosaiced image.

Parameters
Stencilarray to store the selected stencils
Inputthe mosaiced image
Width,Heightdimensions of the image
RedX,RedYthe coordinates of the upper-leftmost red pixel

Mosaiced contour stencils are applied to estimate the contour orientation at each pixel. The output array Stencil holds the index of the selected stencil at each point. The orientation estimate at the ith pixel is Stencil[i]*M_PI/8 radians:

       5  4  3
     6,   |   ,2
    7  `, | ,`  1
    0-----+-----0
Orientations described
    by Stencil[i]

The same enumeration of orientations is used internally for the TV array.

Definition at line 51 of file mstencils.c.

Here is the caller graph for this function: