Bitwise AND, OR, XOR and NOT

void bitwise_and(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray())
Calculates the per-element bit-wise conjunction of two arrays or an array and a scalar.
Parameters:
  • src1 – first input array or a scalar.
  • src2 – second input array or a scalar.
  • src – single input array.
  • value – scalar value.
  • dst – output array that has the same size and type as the input arrays.
  • mask – optional operation mask, 8-bit single channel array, that specifies elements of the output array to be changed.
The function calculates the per-element bit-wise logical conjunction for:
  • Two arrays when src1 and src2 have the same size:
    \texttt{dst} (I) =  \texttt{src1} (I)  \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
  • An array and a scalar when src2 is constructed from Scalar or has the same number of elements as src1.channels():
    \texttt{dst} (I) =  \texttt{src1} (I)  \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0
  • A scalar and an array when src1 is constructed from Scalar or has the same number of elements as src2.channels():
    \texttt{dst} (I) =  \texttt{src1}  \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
void bitwise_not(InputArray src, OutputArray dst, InputArray mask=noArray())
Inverts every bit of an array.
void bitwise_or(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray())
Calculates the per-element bit-wise disjunction of two arrays or an array and a scalar.
void bitwise_xor(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray())
Calculates the per-element bit-wise “exclusive or” operation on two arrays or an array and a scalar.

Example:

-----------
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;
using namespace std;

int main(  )
{
    Mat drawing1 = Mat::zeros( Size(400,200), CV_8UC1 );
    Mat drawing2 = Mat::zeros( Size(400,200), CV_8UC1 );

    drawing1(Range(0,drawing1.rows),Range(0,drawing1.cols/2))=255; imshow("drawing1",drawing1);
    drawing2(Range(100,150),Range(150,350))=255; imshow("drawing2",drawing2);

    Mat res;
    bitwise_and(drawing1,drawing2,res);     imshow("AND",res);
    bitwise_or(drawing1,drawing2,res);      imshow("OR",res);
    bitwise_xor(drawing1,drawing2,res);     imshow("XOR",res);
    bitwise_not(drawing1,res);              imshow("NOT",res);


    waitKey(0);
    return(0);
}
-----------

 Result:


50 comments:

  1. A basic doubt-don't we need namedWindow() before imshow()?

    ReplyDelete
    Replies
    1. Yes. Naming a window is a good practice.
      However, if you are not creating a window, then it will be automatically created.

      Delete
    2. Learn Opencv By Examples: Bitwise And, Or, Xor And Not >>>>> Download Now

      >>>>> Download Full

      Learn Opencv By Examples: Bitwise And, Or, Xor And Not >>>>> Download LINK

      >>>>> Download Now

      Learn Opencv By Examples: Bitwise And, Or, Xor And Not >>>>> Download Full

      >>>>> Download LINK Oc

      Delete
  2. Thank you sir! I have reached here.

    ReplyDelete
  3. Mở bán dự án Eco Dream giá gốc từ chủ đầu tư Việt Hưng

    ReplyDelete
  4. I like your blog, I read this blog please update more content on hacking, further check it once at python online course

    ReplyDelete
  5. Nice blog, thank you so much for sharing with us this valuable information. Get the best Mutual Fund Advice and Investment schemes in top mutual funds by Mutual Fund Wala.
    Mutual Fund Agent

    ReplyDelete
  6. Such great information. But if you are in doubt with your partner.dont worry Call Dr. Vinod Raina @ 9871605858 for HIV/PEP /PrEP Treatment in Delhi.

    ReplyDelete
  7. This is really good blog information thanks for sharing .I am really impressed with your writing abilities 


    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร Gclub กับทางทีมงานของเราเพียงเท่านั้น
    ร่วมมาเป็นส่วนหนึ่งกับเว็บไซต์คาสิโนออนไลน์ของเราได้เลยค่ะ
    สมัครสล็อตออนไลน์ >>> goldenslot
    สนใจร่วมลงทุนกับเรา สมัครเอเย่น Gclub คลิ๊กได้เลย

    ReplyDelete
  8. Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man,Keep it up.
    Abroad education consultants in delhi
    Overseas Education Consultants in Delhi

    ReplyDelete
  9. Very Amazing Blog! This very comprehensive but very easily understand to me. Really well post and very helpful for me.

    amazing post written ... It shows your effort and dedication. Thanks for share such a nice post.Java training in Chennai

    Java Online training in Chennai

    Java Course in Chennai

    Best JAVA Training Institutes in Chennai

    Java training in Bangalore

    Java training in Hyderabad

    Java Training in Coimbatore

    Java Training

    Java Online Training


    ReplyDelete
  10. Nice information, valuable and excellent design Ao, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
    DevOps Training in Chennai

    DevOps Online Training in Chennai

    DevOps Training in Bangalore

    DevOps Training in Hyderabad

    DevOps Training in Coimbatore

    DevOps Training

    DevOps Online Training

    ReplyDelete
  11. Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.Very useful and informative content has been shared out here, Thanks for sharing it


    Azure Training in Chennai

    Azure Training in Bangalore

    Azure Training in Hyderabad

    Azure Training in Pune

    Azure Training | microsoft azure certification | Azure Online Training Course

    Azure Online Training

    ReplyDelete
  12. While using a washing machine we will face several problems in the washing machine. IFB Washing Machine Service Center in Secunderabad Meanwhile, if we get trouble with the washing machine we will confuse where to repair service.

    ReplyDelete
  13. Wow!! Really a nice Article about Angular Js. Thank you so much for your efforts. Definitely, it will be helpful for others. I would like to follow your blog. Share more like this. Thanks Again.
    python training in bangalore

    python training in hyderabad

    python online training

    python training

    python flask training

    python flask online training

    python training in coimbatore

    ReplyDelete
  14. Thank you so much for sharing these amazing tips. I must say you are an incredible writer, I love the way that you describe the things. Please keep sharing.
    Java Training in Chennai

    Java Training in Bangalore

    Java Training in Hyderabad

    Java Training
    Java Training in Coimbatore

    ReplyDelete
  15. Samsung Air Conditioner Service Center in Khardanda Mumbai Is your air conditioning not responding well? the proper spot in Mumbai is that the Samsung AC fix-it shop . We offer at the doorstep service with honest people. Our technicians can repair all verities of air conditioners during a jiffy. Samsung Refrigerator Repair in Kandivali Bandra Mumbai Samsung side by side refrigerator will save more energy with Samsung Energy Star certified side-by-side refrigerators. Store more food and beverages with abundant fridge space and easily make and access ice with the special Slim Indoor home appliance. People are getting to keep their fresh foods in Refrigerators we take at affordable rates. Samsung Refrigerator Repair Service in Santacruz Mumbai Samsung Repair Center in Mumbai, Peoples are using the refrigerator everywhere the planet. A number of the ladies do not know the way to operate the system of the refrigerator and that they will keep the once heat of cooling, or medium temperature of cooling and coldness of cooling.


    ReplyDelete
  16. . Samsung Microwave Oven Service in Ghat kopar Mumbai SAMSUNG may be a topmost brand in India. In every home having an electrical household appliance, one among the microwave ovens also plays a serious role within the cooking area. But sometimes it's not working properly don’t worry once you get service to your microwave ovens then it works as was common. Samsung Microwave Oven Repair Service in Powai hiranandani Mumbai Are you checking out the simplest SAMSUNG microwave service center in Mumbai? We offer the simplest service in Mumbai for several years. We had an honest repute within the service market and that we are masters in repairs of microwave ovens. Samsung Microwave Oven Service in Thane hiranandani Mumbai Are you trying to find one at your nearest microwave repair market in Mumbai? We are now available in Mumbai also we supply the service at any location in Mumbai. The most common problems are stops within the middle of cooking; the plate isn't spinning, sparking, no light inside, etc.

    ReplyDelete
  17. Our godrej administration focus is the best brand administration focus in India. We have so many brand administrations focuses and furthermore the organizations and furthermore the item. We ought to pick the pick the best item like godrej, whirlpool this administration community will work 24x7.so you can call to our administration place. This the right choice to pick. Bosch Service Center Pune

    ReplyDelete
  18. LG Refrigerator Service Center in Panwel Mumbai We provide all repairs like washing machines, air conditioners, microwave oven refrigerators like all home appliances. If any problem is there contact us our technicians will come to your home we provide doorstep service.

    LG Air Conditioner Service Center in Mumbai MaharashtraNow a day’s air conditioners are using in every house so any problem is there in your air conditioners contact us we will send our technicians they will solve the problem and our service good technicians in the air conditioner repairs .

    LG Air Conditioner Repair Center in Mumbai MaharashtraAre you looking at the LG Air Conditioner repair center? They will solve your issue and say the problem of your product and we respond very quickly.LG is the best company for all home appliances .

    ReplyDelete
  19. When a person gets involved in sexual activity, the person also needs to know that PE or premature ejaculation can happen.

    ReplyDelete
  20. Thanks For Sharing.....
    If you are searching for reliable Quickbooks Error Code 6000 Contact us +1 877-751-0742 for immediate help .Our QuickBooks Customer Service Number is available 24*7 for our users.

    ReplyDelete
  21. Thank you for the information it helps me a lot we are lokking forward for more
    AI Training in Hyderabad

    ReplyDelete
  22. thanks for sharing the info we look forward for more it is so good
    datascience Training in Hyderabad

    ReplyDelete
  23. Hi, Thanks for sharing nice articles...

    Website Redesign Services

    ReplyDelete
  24. Learn Opencv By Examples: Bitwise And, Or, Xor And Not >>>>> Download Now

    >>>>> Download Full

    Learn Opencv By Examples: Bitwise And, Or, Xor And Not >>>>> Download LINK

    >>>>> Download Now

    Learn Opencv By Examples: Bitwise And, Or, Xor And Not >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete
  25. Fairly certain he will have a good read.I appreciate your writing effort. Thank you for sharing! 바카라사이트

    ReplyDelete
  26. You need to take part in a contest for one of the best sites online. I’m going to highly recommend this web site! Thank you for hard work 바카라사이트인포

    ReplyDelete
  27. Indoor Led Lights Manufacturer in Gwalior

    ReplyDelete
  28. That is a really excellent piece anyone needs to investigate thank you for sharing. The Color Personality Test is frequently used in personal development workshops, seminars, and self-help books to encourage introspection and encourage positive change.

    ReplyDelete