Issue
So I have this original image:
Then I have it's YDbDR conversion:
it's separated by red, blue and green channels which I know aren't equivalent to YDbDr, but should give a good general gauge on whether the channels have been converted correctly. As you can see Db and Dr equivalently are heavily pixelated when they shouldn't be.
Here's the code:
def RGB_to_YDbDr(obs_RGB):
r = obs_RGB[:, 0]
g = obs_RGB[:, 1]
b = obs_RGB[:, 2]
y = 0.299 * r + 0.587 * g + 0.114 * b
db = -0.450 * r + -0.883 * g + 1.333 * b
dr = -1.333 * r + 1.116 * g + 0.217 * b
return torch.stack([y, db, dr], -3)
I followed Kornia augmentation library's code for RGB to YCbCr to implement RGB to YDbDr. What did I do wrong? Why does Db and Dr look so pixelated? The input images are 100 x 100.
Note:
I tried kornia.color.rgb_to_ycbcr
and got this:
Also seems very heavily pixelated
Solution
Look closely. Your source image is compressed already. What you see is the "chroma subsampling" that is done by image compression. You see blocks of color distortion.
That is exactly what you see in your color (chroma) planes.
Nooo this has nothing to do with plotting or anything. Your source image is compressed. You can only fix that if you have an uncompressed source image, or one that isn't so severely compressed.
Answered By - Christoph Rackwitz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.