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'.

grainy' and 'reddish

When I perform a contrast stretch I get this:

contrast stretch

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?

  • $\begingroup$ Your last filtering will just smear the red channel over a larger area, which is probably counter-productive. Did you ever find a resolution? $\endgroup$
    – Peter K.
    Commented Jun 29, 2016 at 12:18
  • 1
    $\begingroup$ @PeterK. hi i did not. i had to increase the number of lines to get a better copy $\endgroup$ Commented Jun 29, 2016 at 12:59
  • $\begingroup$ 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). $\endgroup$
    – Louis Lac
    Commented Jul 20, 2018 at 12:27

2 Answers 2


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.

  • $\begingroup$ Hi, interesting. Will see if it is exposed by EMGU as I am using the C# wrapper around OpenCV $\endgroup$ Commented Mar 6, 2015 at 10:23
  • $\begingroup$ I could not see it in the object browser. I have sent an email to the author to find out $\endgroup$ Commented Mar 6, 2015 at 10:26
  • $\begingroup$ 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. $\endgroup$
    – Loufylouf
    Commented Mar 6, 2015 at 10:31
  • $\begingroup$ Hi, unsure I would implement that. using Windows OS and I am streaming rtsp via VLC into my C# app $\endgroup$ Commented Mar 6, 2015 at 10:33
  • 1
    $\begingroup$ 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. $\endgroup$
    – Loufylouf
    Commented Mar 6, 2015 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

  • $\begingroup$ 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! $\endgroup$ Commented Mar 6, 2015 at 7:49
  • $\begingroup$ 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. $\endgroup$
    – andrew
    Commented Mar 6, 2015 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.