in Education by
I have an image of a puzzle piece that i need to resize in order for both the pieces I need to compare to have the same size. I have used the following codes to resize my image. The problem is the length of the line in the image 1 is 187 and after resizing the length of the line in image 2 is 194. intended output is for them to be same ratio = math.hypot(x2 - x1, y2 - y1) / math.hypot(x4 - x3, y4 - y3) print("img1", math.hypot(x2 - x1, y2 - y1),"img 2", math.hypot(x4 - x3, y4 - y3)*ratio) n = int(ratio * new_img_2.shape[0]) img = cv2.resize(new_img_2, (n, n), cv2.INTER_CUBIC) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I'm not entirely sure what you're asking but it seems like you want to resize two images and maintain aspect ratio between the two. If so, here's a function to resize a image and maintain aspect ratio to any width or height. import cv2 # Resizes a image and maintains aspect ratio def maintain_aspect_ratio_resize(image, width=None, height=None, inter=cv2.INTER_AREA): # Grab the image size and initialize dimensions dim = None (h, w) = image.shape[:2] # Return original image if no need to resize if width is None and height is None: return image # We are resizing height if width is none if width is None: # Calculate the ratio of the height and construct the dimensions r = height / float(h) dim = (int(w * r), height) # We are resizing width if height is none else: # Calculate the ratio of the 0idth and construct the dimensions r = width / float(w) dim = (width, int(h * r)) # Return the resized image return cv2.resize(image, dim, interpolation=inter) if __name__ == '__main__': image = cv2.imread('../color_palette.jpg') cv2.imshow('image', image) cv2.waitKey(0) resized = maintain_aspect_ratio_resize(image, width=400) cv2.imshow('resized', resized) cv2.waitKey(0) You may want to rephrase your question to be more clear.

Related questions

0 votes
    From which panel do we have to select image layer to resize the imported image? History Panel None Layers Panel Params Panel Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    Im trying to make a drawable xml resource to use as background for an activity. The background need to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    Im trying to make a drawable xml resource to use as background for an activity. The background need to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    I have a single window with a single custom view in it, and I want the custom view to resize ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    $('#some-table').DataTable({ "language": { "url": "{{ asset('/js/plugins/lang.json') }} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    $('#some-table').DataTable({ "language": { "url": "{{ asset('/js/plugins/lang.json') }} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    legal and regulatory aspect of Internet and www is refer to what? Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    Which aspect of strategy and investment funding involves developing and communicating the Strategic Themes throughout the portfolio?...
asked Nov 28, 2020 in Technology by JackTerrance
0 votes
    Architecting for scale, modularity, releasability, and serviceability is an aspect of which dimension of Enterprise Solution Delivery?...
asked Nov 27, 2020 in Technology by JackTerrance
0 votes
    I have a UITableView of customers where a row/customer is selected. The user can then push another view ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I have a UITableView of customers where a row/customer is selected. The user can then push another view ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    I have a UITableView of customers where a row/customer is selected. The user can then push another view ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    I have a UITableView of customers where a row/customer is selected. The user can then push another view ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    How should you maintain a deployed model?...
asked Apr 26, 2021 in Technology by JackTerrance
0 votes
    How will you maintain the sessions in MVC?...
asked Dec 8, 2020 in Technology by JackTerrance
...