[Feature request] RGB-YIQ conversion (compose/decompose to layers)


(Kirill Gromov) #1

Hi. For several months, I’ve been trying to recreate the effect of an old VHS tape in GIMP. So far I’ve got pretty nice results, but to make them more accurate, I’d need to decompose an image to YIQ channels, and then compose it back in RGB again.

I’ve searched the web, but there aren’t any programs which can do it for me. I’ve seen several pieces of code in Python, C++ and MathLab, and there are matrixes available for conversion from RGB and other formats. But, alas, at the moment there simply aren’t any standalone programs/plugins which can accomplish this task.

I’m not familiar enough with coding to make a program myself, so I’d like to request this feature in GMIC. I’d appreciate it a lot and it would help me to understand VHS better.


(G'MIC staff) #2

Thanks for the suggestion. I’ve added the RGB<->YIQ transformations in most filters, including Colors / Decompose channels, as illustrated below. Should be available in G’MIC 1.6.7+ after a filter update.


(Kirill Gromov) #3

Thank you! This is great news! I immediately saw some very interesting results after trying it, I’m going to test it further later today.


(Kirill Gromov) #4

I’ve tried testing it further. I have GMIC v1.6.7 plugin for GIMP, I’m using it on Mac OS X.

There are two things I’ve had trouble with. First, for some reason, when I decomposed and recomposed the image back, it was missing blue/green tones. I’ve made an album with the results: http://imgur.com/a/LFiBY. I did everything as usual (the same exact actions but with YCbCr color basis produced normal results). Second, the chroma layers I got seemed a little too high in black, with only few parts in grey/white, which was very different from YCbCr/YUV decomposition (but I don’t know if it should be this way).

It is unexpected because in the picture you posted above everything looks just fine, so I’m not sure where the problem is.

I’ve tried to test it on Windows 10 x64. Unfortunately, when I update the filters, for some reason the YIQ option doesn’t appear. I have 1.6.8_pre version of GMIC plugin. I tried to find v1.6.7 just in case but couldn’t.


(G'MIC staff) #5

The RGB->YIQ and YIQ->RGB transformations do not preserve the value range, and thus, I end up with negative values (or values higher than 255) when I compute the transforms.
In this case, I have to ‘cut’ the values in range [0,255], so that GIMP can handle the image correctly (in 8bits / channel with GIMP 2.8). I guess this explains why you have differences for some color tones.
Maybe on the picture I’ve used, I had the luck to minimize the out-of-range values when computing the color transformation (there are very few blues and green in the image of lena).


(Kirill Gromov) #6

Yes, I assume this is the reason. But, don’t YUV and YCbCr have negative values too? I understand that when decomposing the images in these color spaces in GMIC, chroma values −0.5 will be presented as black, 0—grey, and +0.5—white. Can the same be applied to YIQ? I understand that it’s a little different though, because if I understand correctly I and Q’s ranges slightly exceed [-0,5, +0.5].

Cutting off the negative part brings limitations to what can be done with an image.


(G'MIC staff) #7

Yes, we can still renormalize the values in [0,255] with YIQ, maybe at the price of losing numerical precision for colors that initially fit in the [0,255] range.


(G'MIC staff) #8

Done!
Should work OK now, after a filter refresh.


(Kirill Gromov) #9

Thank you very much! It works great now. Tried several images, everything works perfectly. Can’t wait to try it on VHS images I have, I really like it.