iOS-OpenCV图像混合

2016-11-04  本文已影响118人  沙琪玛dd

code:

- (void)viewDidLoad {
    [super viewDidLoad];
    CGRect rect = [UIScreen mainScreen].bounds;
    self.imgView.frame = rect;
    
    UIImage *image1 = [UIImage imageNamed:@"dog.jpg"];
    UIImageToMat(image1, PictureMatA);
    
    UIImage *image2 = [UIImage imageNamed:@"dog2.png"];
    UIImageToMat(image2, PictureMatB);
    
    double t = (double)getTickCount();
    blending(PictureMatA, PictureMatB, resultPictureMat);
    
    t = ((double)getTickCount() - t)/getTickFrequency();
    cout<< "--------------cost:" << t <<" seconds-----------------" <<endl;
    
    self.imgView.image = MatToUIImage(resultPictureMat);
        
    // Do any additional setup after loading the view, typically from a nib.
}

void blending (const Mat& pictureA ,const Mat& pictureB, Mat& resultPicture)
{
        float alpha = 0.2f,beta;
        beta = 0.8;
        addWeighted(pictureA, alpha, pictureB, beta, 0.0, resultPicture);
}
dog+dog2.png
上一篇下一篇

猜你喜欢

热点阅读