4 Replies Latest reply on Jun 10, 2014 8:58 AM by Dalavi

    Is it possible to use CONTRAST DETECTION as a method of Applying Mask/Matte?


      This might be one of those most stupid questions but I would still like to put it forward and hopefully I can get some answers that can satisfy my curiosity.

      I came across this question when I was thinking about how I can color-grade the subject independently without defining a range of colour as skin colour, or peel the subject off the background and add something in between without roto-scoping. Then I thought of auto-focus and whether it is possible to reverse the process of auto-focusing and actually distinct which proportions of the image are in-focus and which are out-of-focus. Usually I shoot with a narrow depth of field and I think the BG would be blurred quite a bit. So is it possible to extract the in-focus areas from the out-of-focus areas?

      So is the process of contrast detection or edge detection or feature detection (or phase detection) during an auto-focus irreversible?

      Or does it require dynamic variations (to get different samples) to compare and assess values?

      Or is this process limited to perform in only a tiny area rather than an entire image, and would take too much processing power if applied to a large area?

      Or is it simply that the whole thing is not that practical mathematically?

      A great many thanks to those who would answer this question !

      Wish you all a nice and creative day~

        • 1. Re: Is it possible to use CONTRAST DETECTION as a method of Applying Mask/Matte?
          Rick Gerard Adobe Community Professional & MVP

          It is possible to use channel information to extract a matte. This  information comes from color or luminance values. This is called a procedural matte. Usually you would duplicate your footage layer and start applying color effects to isolate certain areas of color or luminance, and then you use that footage as a luminance matte for the layer below.


          That said, while it is fairly easy to find edge detail (Find Edges effect) it is extremely difficult to figure out which of those edges should be inside or outside the desired mask area. Trying to deconstruct the auto focus feature a camera uses from the image data would be quite a daunting task and I'm not sure how effective that would be because there is currently no metadata that would tie any part of the frame to something like the face of the person you wanted to use as a mask. Face detection algorithms may have a chance at doing this for faces, but the other parts of the body would be extremely difficult to figure out.


          Stereo Photography may offer a solution to extracting a procedural matte from the part of your shot that is in focus providing you took great care setting up proper convergence for the image pairs, but this would not isolate skin tones.


          Rotobrush is an automated tool that asks user input to define the inside of the desired mask that uses edge detection and color values. It is very effective if you take care with the original photography, but if you are not careful automatic roto using any tool becomes difficult if not impossible. After the fact visual effects are way more complicated if there is no production planning.


          Colorista II is my favorite tool for this kind of color correction. It has a very effective internal matte tool that can do amazing things using color range. Other color correctors (Davinci for example) have other tools to isolate areas based on color or luminance values. Your idea is interesting, but it would be very difficult to pull off using AE's current set of tools.

          • 2. Re: Is it possible to use CONTRAST DETECTION as a method of Applying Mask/Matte?
            Szalam Adobe Community Professional & MVP

            Perhaps you could use Find Edges and the paintbucket effect to create some stuff on the outside of the subject which could then be reversed, but it wouldn't be a very clean key at all.


            I don't think this would work very well. However, your description of your shots sounds like the Roto Brush would do very well with it especially when used with the Refine Matte tweaks

            • 3. Re: Is it possible to use CONTRAST DETECTION as a method of Applying Mask/Matte?
              Dalavi Level 1

              Thanks Rick! Sounds like I'd been a little bit far-fetched.


              I've also been using Colorista II and did find it handy. I was just picking up some random ideas from the middle of nowhere, trying to figure out if there were some other way round.


              But now my question seems quite settle~

              • 4. Re: Is it possible to use CONTRAST DETECTION as a method of Applying Mask/Matte?
                Dalavi Level 1

                Thanks Szalam! For your answer. Roto-scoping really worked quite well in most cases. I was just wondering if there were another approach.


                But anyway you've also been helpful!