尺寸调整:resize()函数
resize(InputArray src,
OutputArray dst,
Size dsize,
double fx =0,
double fy =0,
int interpolation =INTER_LINEAR
);
resize 两种调用范例:
方式一
NSString*image =@"456.png";
UIImage*image1 = [UIImageimageNamed:image];
Mat im;
UIImageToMat(image1, im);
if(im.empty()) {
return;
}
resize(im,dst,cv::Size(1000,10));
self.secondImageView.image=MatToUIImage(dst);
方式二
NSString*image =@"456.png";
UIImage*image1 = [UIImageimageNamed:image];
Mat im;
UIImageToMat(image1, im);
if(im.empty()) {
return;
}
resize(im,dst,cv::Size(),0.1,0.1);
self.secondImageView.image=MatToUIImage(dst);
图像金字塔相关的API函数
图像金字塔相关的API函数主要是pyrUp和pyrDown这一对
(1)向上采样:pyrUp()函数
pyrUp()函数的作用是向上采样并模糊一张图像,说白了就是放大一张图片
pyrUp(InputArray src,
OutputArray dst,
const Size& dstsize =Size(),
int borderType =BORDER_DEFAULT
);
代码示例
NSString*image =@"words.jpg";
UIImage*image1 = [UIImageimageNamed:image];
Mat im;
UIImageToMat(image1, im);
if(im.empty()) {
return;
}
//resize(im, dst,cv::Size(),0.1,0.1);
pyrUp(im,dst);
Mat dst1;
pyrU p(dst, dst1);
Mat dst2;
pyrUp(dst1, dst2);
Mat dst3;
pyrUp(dst2, dst3);
self.secondImageView.image=MatToUIImage(dst3);
(2)采样:pyrDown()
作用是向下采样并模糊一张图片,说白了就是缩小一张图片。
pyrDown(InputArray src,
OutputArray dst,
constSize& dstsize =Size(),
int borderType =BORDER_DEFAULT
);
代码示例:
NSString*image =@"words.jpg";
UIImage*image1 = [UIImageimageNamed:image];
Mat im;
UIImageToMat(image1, im);
if(im.empty()) {
return;
}
//resize(im, dst,cv::Size(),0.1,0.1);
pyrDown(im,dst);
Matdst1;
pyrDown(dst, dst1);
Matdst2;
pyrDown(dst1, dst2);
Matdst3;
pyrDown(dst2, dst3);
self.secondImageView.image=MatToUIImage(dst3);
效果展示
网友评论