尺寸調整: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);
效果展示