preface

  • This article will introduce image fusion using OpenCV

The theory of

Linear mixing operation G (x)=(1−α)f0(x) + αf1(x), where the value of α ranges from 0 to 1, f0(x) represents the color data of pixels at x position of one image, and F1 (x) represents the color data of pixels at x position of another image

The core idea

Determine whether the two images have the same size. 2. Determine whether the UIImage type is consistent

Code demo

/ - (UIImage*)kj_opencvBlendImage:(UIImage*)image alpha:(double)alpha{if (! CGSizeEqualToSize(self.size, image.size)) { image = [image kj_BitmapChangeImageSize:self.size]; } cv::Mat src,src2,dst; UIImageToMat(self,src,true); UIImageToMat(image,src2,true); if (src.type() ! = src2.type()) { return self; } addWeighted(SRC, alpha, SRc2, 1.0-alpha, 0.0, DST); return kMatToUIImage(dst); }Copy the code

figure

Serial article association

1, how to use OpenCV in iOS project 2, iOS using OpenCV to adjust the image brightness and contrast (1) 3, iOS using OpenCV image fusion (2) 4, iOS using OpenCV filter processing (3)

Then I will slowly added Opencv related articles, temporarily to common image processing and image algorithms encapsulation, friends in need can be to pod ‘KJExtensionHandler/Opencv’

How to use OpenCV in iOS project introduction to this end, there are related to supplement, writing articles is not easy, but also please click **Little stars* * portal