Hi folks,

I thought I'd report on this list a recent discussion with cehteh about
the Cin chroma-key plugins.

As I mentioned to cehteh, I've been working on y4m, a python-based
framework for scripted video editing.

With just half an hour's work, I was able to come up with a chromakey
plugin for y4m that in many respects totally blew both the Cin chromakey
effects out of the water.

What I've done in my chromakey is:

  - let user choose an area of the chromakey fabric for a sample
  - by checking every pixel in the sample, calculate average Cb and Cr,
    (call this avgCb, avgCr)
  - for every pixel in the frame:
      - dCb = pixelCb - averageCb
      - dCr = pixelCr - averageCr
      - difference = (pixCb - avgCb)^2 + (pixCr - avgCr)^2
      - if difference < threshold
           make pixel transparent
        else
           copy pixel intact

This very simple approach (testing if the sum of squares of each pixel's
Cb and Cr differences from the sampled average Cb and Cr is less than a
user-specified threshold) gives excellent accuracy with a very wide
margin of error, even with poor chroma fabric and poor lighting. Doesn't
take much for the user to find a threshold that works throughout the
clip. Notice too that luma is completely ignored - no need to even look
at it.

I wonder if Cin might benefit from someone trying this simple algo
within one of the Cin chromakey plugins, or even forking the basic
chromakey to a new 'CbCr ChromaKey' plugin. It'd try it myself if my
present stream of thought allowed for learning the Cin plugin
architecture.

The downside of my approach is edge noise. This is largely a chroma
fabric and lighting problem (I hope to buy some better chroma cloth
soon). I do notice that Cin has some edge noise in the same conditions
though.

I've tried some edge noise reduction, based on giving each non-key pixel
a transparency proportional to how many key pixel neighbours it has
within a given radius (usually 1-2). This cuts the visible noise
markedly but doesn't eliminate it. I might try adding some edge blurring
code to see if this gets the noise within a tolerable level.

Cheers
David

PS - on my TODO list is writing extra y4m plugins to give the capability
needed to create in y4m the same node setup as in that excellent Blender
keying tutorial page.




_______________________________________________
Cinelerra mailing list
Cinelerra@skolelinux.no
https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra

Reply via email to