Home > C++, ImageProcessing, OpenCv > OpenCv IplImage how to clear or initialize the image to scalar

OpenCv IplImage how to clear or initialize the image to scalar

just use the cvSet

e.g if img is the IplImage object pointer with 3 channels.

cvSet(img, cvScalar(0,0,0));

will set each and every pixel to zero.

Becarefull with the  channels and cvScalar used.

Advertisements
  1. Aditya
    March 11, 2010 at 9:57 am

    Useful tip, thanks!

  2. mohsenam
    July 7, 2010 at 7:07 am

    Glad that it could be of any help

  3. Stéphane Péchard
    January 13, 2012 at 4:07 pm

    There is even a smaller version called cvZero, which put 0 on every pixel: cvZero(img);
    😉

    • mohsenam
      January 13, 2012 at 10:48 pm

      thanks Stephane,
      I was trying to set it to some value other than zero 🙂 e.g. all ones, or all blue color, etc… that’s why I was not using cvZero.

  4. Huy
    March 20, 2012 at 2:07 pm

    Thanks a lot, mohsenam. It’s very handy!

    • mohsenam
      March 20, 2012 at 6:42 pm

      thanks, it was nothing, just when I was trying to learn some initial things.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: