Skip to main content

Posts

Showing posts with the label Mask

OpenCV : Image synthesis (ROI, Mask, Binary)

Today we will make Image synthesis by using ROI, Masking, binarization. The full code is like that. #include <iostream> #include "opencv2/opencv.hpp" using namespace std ; using namespace cv ; int main () { Mat me = imread( "./res/pic/mh.jpg" ); Mat animal = imread( "./res/pic/animal_head.png" ); Mat animalGray ; Mat mask_ani ; Mat mask_ani_inv ; imshow( "me origin" , me ); imshow( "animal" , animal ); cvtColor( animal , animalGray , CV_BGR2GRAY); // color to black and white threshold( animalGray , mask_ani , 10 , 255 , 0 ); // make binary bitwise_not( mask_ani , mask_ani_inv ); imshow( "mask ani inv" , mask_ani_inv ); imshow( "mask ani" , mask_ani ); Mat imgRoi ; imgRoi = me ( Rect ( 50 , 50 , animal . cols , animal . rows ) ) ; imshow( "imgRoi" , imgRoi ); Mat me_back ; Mat ani_for ; bitwise_and( animal ...