# Removing the 'red' artifact from my JPEG

I have a JPEG that originally came from a IP Camera. I have converted the JPEG to a bytes and have uploaded it to my server. Upon receiving it on my server I save it to disk.

When I view the image it looks 'grainy' and 'reddish'.

When I perform a contrast stretch I get this:

When I perform a Hist-Equalization I get this:

N.B. I have also tried a filter just on the Red Channel:

Image<Bgr, byte> CurrentFrame = new Image<Bgr, byte>((Bitmap)picOriginal.Image.Clone());
CvInvoke.cvSmooth(CurrentFrame[2], CurrentFrame[2], SMOOTH_TYPE.CV_GAUSSIAN, 3, 3, 1.5, 0);


Is there another approach so I could make the image look better, 'balanced', if that makes sense?

• Your last filtering will just smear the red channel over a larger area, which is probably counter-productive. Did you ever find a resolution? – Peter K. Jun 29 '16 at 12:18
• @PeterK. hi i did not. i had to increase the number of lines to get a better copy – Andrew Simpson Jun 29 '16 at 12:59
• I can't remember the name of this phenomenon but it was quite common with low quality camera. As pointed out by @Loufylouf white balance is a good solution try! Especially the pink-green slider for hue/saturation (move it toward green direction). – Louis Lac Jul 20 '18 at 12:27

Did you try to change the white balance of your image ? Apparently there's a function (balanceWhite) in OpenCV that tries to correct the white balance, you might want to give it a go.

• Hi, interesting. Will see if it is exposed by EMGU as I am using the C# wrapper around OpenCV – Andrew Simpson Mar 6 '15 at 10:23
• I could not see it in the object browser. I have sent an email to the author to find out – Andrew Simpson Mar 6 '15 at 10:26
• You can also try to take a picture from your camera, use Gimp's (or photoshop) auto white balance feature and see what changes it made on the different channels, and then apply it to your stream. – Loufylouf Mar 6 '15 at 10:31
• Hi, unsure I would implement that. using Windows OS and I am streaming rtsp via VLC into my C# app – Andrew Simpson Mar 6 '15 at 10:33
• Well, you can consider that the red artifact is permanent (dependant of your camera), so you only have to use gimp or photoshop once, fetch the correction it applied on the channels, and hard code it into your application. That's almost equivalent to use the balanceWhite function of openCV. – Loufylouf Mar 6 '15 at 10:40

Try running a Gaussian kernel over it? Maybe even just over the red channel, if that is the one that bugs you the most. Applying it to only one channel will also reduce the blurring effect

• Hi Andrew, thanks fro your suggestion. I gave it a go but I could not see any changes. I updated my question with the code I used for this - just in case I coded it wrong! – Andrew Simpson Mar 6 '15 at 7:49
• Your code looks good actually. Looking at the image though, I see now there would be some green leftover, even if the red thing worked. I'm guessing all those artifacts are coming from the jpg compression. Do you have any control over this? Maybe a camera setting? It looks like it is simply too high and resulting in a poor image. Do you need to process a color image? Maybe you can convert it to b&w and run a median filter over it to eliminate the artifacts. – andrew Mar 6 '15 at 17:41