Doing the computation per RGB channel would introduce chromatic shifts.  My guess is that chromatic scaling is probably uniform (either across channels or  adjusting the saturation of the image in a non-spatially variant manner).

Some of the best of breed work on this topic is by Sylvain Paris, a researcher also at Adobe:
http://people.csail.mit.edu/sparis/publi/2011/siggraph/

You can use it to boost certain spatial scales to increase local contrast and reconstruct an image without artifacts.


On Thu, Oct 24, 2013 at 6:45 PM, Juan Nunez-Iglesias <jni.soma@gmail.com> wrote:
Thanks Josh, Jerome,

Actually what I'm really after is a good, local foreground/background correction. The local bit is what attracted me to Clarity even though it's not really what I'm after. 

Particularly of interest is something that will be robust to artifacts in the images.

Juan.

On Fri, Oct 25, 2013 at 10:13 AM, Josh Warner <silvertrumpet999@gmail.com> wrote:
I think that's on the right track.

But a naive contrast mask affects only the luminance. In the first example the colors are also very punched up; just looking this seems like more than a simple global contrast mask.

My guess? They're applying the equivalent of a contrast mask, but to each RGB channel separately. This is "wrong" from an image processing perspective, but in the world of Instagram it seems people are more interested in filters than reality.

I wouldn't be against this for advertising purposes, though I'd never do it to my own images.

On Thursday, October 24, 2013 2:03:22 AM UTC-5, Jerome Kieffer wrote:
On Thu, 24 Oct 2013 17:27:55 +1100
Juan Nunez-Iglesias <jni....@gmail.com> wrote:

> Hi guys,
>
> Does anyone here have any ideas about what the Camera+ Clarity filter is
> doing? Some examples of the filter
> here<https://secure.flickr.com/photos/pierrewikberg/6983939966/>and
> here <http://obamapacman.com/2011/03/enhance-iphone-camera-clarity-video/>.
>
> Might be a nice addition to skimage.exposure... =)

Looks like a contrast mask:
http://www.gimp.org/tutorials/ContrastMask/

Here is an old implementation, starting from a JPEG:
    def contrastMask(self, outfile):
        """Ceci est un filtre de debouchage de photographies, aussi appelé masque de contraste,
        il permet de rattrapper une photo trop contrasté, un contre jour, ...
        Écrit par Jérôme Kieffer, avec l'aide de la liste python@aful,
        en particulier A. Fayolles et F. Mantegazza avril 2006
        necessite numpy et PIL.
       
        @param: the name of the output file (JPEG)
        @return: filtered Photo instance
        """

        try:
            import numpy
#            import scipy.signal as signal
        except:
            logger.error("This filter needs the numpy library available on https://sourceforge.net/projects/numpy/files/")
            return

        t0 = time.time()
        dimX, dimY = self.pil.size

        ImageFile.MAXBLOCK = dimX * dimY
        img_array = numpy.fromstring(self.pil.tostring(), dtype="UInt8").astype("float32")
        img_array.shape = (dimY, dimX, 3)
        red, green, blue = img_array[:, :, 0], img_array[:, :, 1], img_array[:, :, 2]
        #nota: this is faster than desat2=(ar.max(axis=2)+ar.min(axis=2))/2
        desat_array = (numpy.minimum(numpy.minimum(red, green), blue) + numpy.maximum(numpy.maximum(red, green), blue)) / 2.0
        inv_desat = 255. - desat_array
        blured_inv_desat = self._gaussian.blur(inv_desat, config.ContrastMaskGaussianSize)
        bisi = numpy.round(blured_inv_desat).astype("uint8")
        k = Image.fromarray(bisi, "L").convert("RGB")
        S = ImageChops.screen(self.pil, k)
        M = ImageChops.multiply(self.pil, k)
        F = ImageChops.add(ImageChops.multiply(self.pil, S), ImageChops.multiply(ImageChops.invert(self.pil), M))
        exitJpeg = op.join(config.DefaultRepository, outfile)
        F.save(exitJpeg, quality=80, progressive=True, Optimize=True)
        try:
            os.chmod(exitJpeg, config.DefaultFileMode)
        except IOError:
            logger.error("Unable to chmod %s" % outfile)
        exifJpeg = Exif(exitJpeg)
        exifJpeg.read()
        self.exif.copy(exifJpeg)
        exifJpeg.comment = self.exif.comment

--
Jerome Kieffer <goo...@terre-adelie.org>

--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--

[  matthew m trentacoste                                     ]
[                                                            ]
[  mt@matttrent.com                                          ]
[  http://matttrent.com                                      ]
[  twitter: @matttrent                                       ]
[  +1.415.326.3226                                           ]