Downsampling without smoothing

Is there a built-in way to smooth the image in OpenCV 2.3.1 without preliminary Gaussian smoothing (which is performed by the pyrDown C ++ function).

Thanks.

+6
source share
3 answers

Maybe you are looking for resize () .

# Python code: import cv2 large_img = cv2.imread('our_large_image.jpg') small_to_large_image_size_ratio = 0.2 small_img = cv2.resize(l_img, (0,0), # set fx and fy, not the final size fx=small_to_large_image_size_ratio, fy=small_to_large_image_size_ratio, interpolation=cv2.INTER_NEAREST) 

Instead of interpolation=cv2.INTER_NEAREST you can use any of these interpolation methods .

+6
source

resize () with interpolation = INTER_NEAREST.

EDIT

hmmm, what if you write a function yourself?

 double factor; int newcols = round(mat.cols*factor); int newrows = round(mat.rows*factor); Mat newmat = Mat(newcol, newrows, mat.type()); for (int i=0;i<mat.cols;i++){ for (int j=0;j<mat.cols;j++){ newmat_<yourtype> (round(i*factor), round(j*factor)) = mat_<yourtype>(i, j); } } 

I did not check if the code works or not (most likely not), but you get the idea.

+1
source

You can use image pyramids: pyrDown, opencv document links http://docs.opencv.org/2.4/doc/tutorials/imgproc/pyramids/pyramids.html

-3
source

Source: https://habr.com/ru/post/914808/


All Articles