Resize image in open cv format

I am partly new to opencv and image processing. I tried this code that I found on pyimagesearch.com . I resized the image to a height of 500 pixels to do edge detection and find outlines.

r = 500.0 / image.shape[1]
dim = (500,int(image.shape[0] * r))
image = cv2.resize(image,dim,interpolation = cv2.INTER_AREA)
ratio  = image.shape[0] /500.0

Again, I multiply the processed image with the ratio (so the changes are made wrt of the original image)

warped = four_point_transform(orig,screenCnt.reshape(4,2)*ratio)
r = 500.0 / warped.shape[1]
dim = (500,int(warped.shape[0] * r))

warped = cv2.resize(warped,dim,interpolation = cv2.INTER_AREA)
cv2.imshow("Perspective Transform",warped)

After that, the results that I get are somewhat similar to Image . Only part of the image is visible, and I cannot see the rest of the image. Please help me. Thanks!

+4
source share
2 answers

, .

image.shape[] , .

, :

newHeight = 500.0
oldHeight = image.shape[0]
oldWidth = image.shape[1]
r = newHeight / oldHeight
newWidth = int(oldWidth * r)
dim = (newHeight, newWidth)
image = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
aspectRatio = image.shape[1] / image.shape[0]
+2

, . ..

http://docs.opencv.org/2.4/doc/tutorials/imgproc/pyramids/pyramids.html

imageSmall = cv2.pyrDown(image) # make image smaller
imageLarger = cv2.pyrUp(image) # make image larger
0

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


All Articles