title: Encode image in JPG with OpenCV avoiding the ghost effect
body: <p>I have an application <strong>(openCV - C++)</strong>  that grab an image from webcam, encode it in JPG and trasmitt it from a Server to Client. Thwebcam is stereo so actually I have two image, LEFT and RIGHT. In the client, when I recieve the image I decode it and I generate an Anaglyph 3D Effect.
  For do this I use the OpenCV...
  Well I encode the image in this way:</p>
  
  <pre><code> params.push_back(CV_IMWRITE_JPEG_QUALITY);
   params.push_back(60); //image quality
   imshow(image); // here the anagliphic image is good!
   cv::imencode(".jpg", image, buffer, params);
  </code></pre>
  
  <p>and decode in this way:</p>
  
  <pre><code> cv::Mat imageRecieved = cv::imdecode( cv::Mat(v), CV_LOAD_IMAGE_COLOR );
  </code></pre>
  
  <p>What I see is that this kind of encode generate in the Anaglyph image a "ghost effect" (artifact?) so there is a bad effect with the edges of the object. If look a door for example there a ghost effect with the edge of the door. I'm sure that this depends of the encode because if I show the Anaglyph  image before encode instruction this work well. I cannot use the PNG because it generate to large image and this is a problem for the connection between the Server and the Client.</p>
  
  <p>I look for the GIF but, if I understood good, is nt supported by the cv::encode function.</p>
  
  <p>So there is another way to encode a cv:Mat obj in JPG withou this bad effect and without increase to much the size of the image?</p>