RGB tensor to YDbDr

Dylan_Yung: <aside class="onebox wikipedia" data-onebox-src="https://en.wikipedia.org/wiki/YDbDr">
  <header class="source">

      <a href="https://en.wikipedia.org/wiki/YDbDr" target="_blank" rel="noopener nofollow ugc">en.wikipedia.org</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:167/500;"><img src="//upload.wikimedia.org/wikipedia/en/thumb/5/5e/YDbDr_components.jpg/220px-YDbDr_components.jpg" class="thumbnail" width="167" height="500"></div>

<h3><a href="https://en.wikipedia.org/wiki/YDbDr" target="_blank" rel="noopener nofollow ugc">YDbDr</a></h3>

<p>YDbDr, sometimes written YDBDR, is the colour space used in the SECAM analog terrestrial colour television broadcasting standard (adopted in France and some countries of  the former Eastern Bloc) and PAL-N (adopted in Argentina, Paraguay and Uruguay).  It is very close to YUV (used on the PAL system) and its related colour spaces such as YIQ (used on the NTSC system), YPbPr and YCbCr.
 YDbDr is composed of three components - 
  
    
      
        Y
      
    
    {\displaystyle Y}
  
, 
  
   ...</p>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>Is there a way to convert a RGB tensor to YDbDr? I’m assuming maybe not. This seems like a basic question but I never verified that indexes representing the channels in in the tensor correspond to a color like: 0, 1, 2 = R, G, B, because if so then I should be able to take a tensor of Batch x RGB x Height x Width and use the equation in the wikipedia article.</p>

InnovArul: <p>Kornia might help you to achieve this.<br>
<a href="https://kornia.readthedocs.io/en/latest/color.html#ycbcr" class="onebox" target="_blank" rel="noopener">https://kornia.readthedocs.io/en/latest/color.html#ycbcr</a></p>

Dylan_Yung: <p>is YCbCr the same as YDbDr? Pretty sure this is different.</p>

InnovArul: <p>Yes, they seem to be different.<br>
You could look at the source code of YCbCr and adapt it to YDbDr.</p>
<p><a href="https://kornia.readthedocs.io/en/latest/_modules/kornia/color/ycbcr.html#rgb_to_ycbcr" class="onebox" target="_blank" rel="noopener">https://kornia.readthedocs.io/en/latest/_modules/kornia/color/ycbcr.html#rgb_to_ycbcr</a></p>
<aside class="quote no-group" data-username="Dylan_Yung" data-post="1" data-topic="154252">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dylan_yung/48/15225_2.png" class="avatar"> Dylan_Yung:</div>
<blockquote>
<p>then I should be able to take a tensor of Batch x RGB x Height x Width and use the equation in the wikipedia article.</p>
</blockquote>
</aside>
<p>Either way, to answer your question, Yes. You can take the RGB tensor and use the mapping equation in Wikipedia/elsewhere to convert RGB to YDbDr.</p>
<aside class="quote no-group" data-username="Dylan_Yung" data-post="1" data-topic="154252">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dylan_yung/48/15225_2.png" class="avatar"> Dylan_Yung:</div>
<blockquote>
<p>but I never verified that indexes representing the channels in in the tensor correspond to a color like: 0, 1, 2 = R, G, B</p>
</blockquote>
</aside>
<p>Also, RGB indices depend on the library that’s used to load the images. As I know, Numpy/Scipy libraries load RGB channels in indices 0,1,2 respectively, and OpenCV loads RGB channels in indices 2,1,0 by default.</p>