Convert polygon to real coodinates in image

ĐÀO MINH KHÁNH 10 Reputation points
2024-03-05T08:12:30.08+00:00

image

Hello. I get response API from Azure Document Intelligence Layout Model and I want to extract bounding box cells, columns, and rows. But I still haven't found a way to convert polygon output to a bounding box(x_min, y_min, x_max, y_max), because the image has size (1656, 2339) but the polygon coordinates are quite small ( < 20)

My question is: How to convert a polygon into bounding box format?

The pdf input and the API response have the below result:

{
						"rowIndex": 1,
						"columnIndex": 0,
						"content": "TÀI SẢN NGẮN HẠN",
						"boundingRegions": [
							{
								"pageNumber": 1,
								"polygon": [
									0.9917,
									2.017,
									3.9064,
									2.0353,
									3.9064,
									2.3276,
									0.9917,
									2.3276
								]
							}
						],
						"spans": [
							{
								"offset": 219,
								"length": 16
							}
						]





					}
Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
2,109 questions
{count} votes

1 answer

Sort by: Most helpful
  1. dupammi 8,615 Reputation points Microsoft External Staff
    2024-03-05T09:21:29.7966667+00:00

    Hi @ĐÀO MINH KHÁNH

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer.

    x_min = 0.9917 / width * 1656 
    y_min = 2.017 / height * 2339 
    x_max = 3.9064 / width * 1656 
    y_max = 2.3276 / height * 2339
    

    where width and height can be obtained from the API response.


    Please do not forget to click Accept Answer and Yes for was this answer helpful. This can be beneficial to other community members.

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.