# US 12,602,791 B2 · Visual segmentation of documents contained in files

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,602,791 B2
- Document ID: US12602791B2
- Status: Granted
- Kind: B2
- Application number: 18/342,612
- Filed: 2023-06-27
- Published: 2024-10-31
- Granted: 2026-04-14
- Earliest claimed: 2023-04-26
- Assignees: Base64.ai, Inc.
- Applicants: Base64.ai, Inc.
- Inventors: Ozan Eren Bilgen; Alperen Sahin; Begum Yalcin; Can Korkut; Ihsan Soydemir
- Web page: https://patentgrep.com/patent/US12602791B2

## CPC

- G06T 7/136: involving thresholding
- G06F 40/103: Formatting, i.e. changing of presentation of documents (automatic justification G06F40/189; automatic line break hyphenation G06F40/191)
- G06T 7/11: Region-based segmentation
- G06T 7/12: Edge-based segmentation
- G06T 2207/20081: Training; Learning
- G06T 2207/20084: Artificial neural networks [ANN]
- G06T 2207/20132: Image cropping
- G06T 2207/30176: Document
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems and methods of the inventive subject matter are directed to artificial intelligence systems that are configured to receive an uploaded file from a user, where that upload contains images of one or more documents. Documents can be, e.g., receipts, identification cards, and so on. Once received, the system converts the image to a tensor to facilitate identifying mask images. The AI system then converts any identified mask images to grayscale before converting the image to black and white. White spaces are identified, and contours are identified that surround the white spaces. Next, white spaces with areas below a threshold size are discarded and white spaces with areas above that threshold have their contours stored. The AI system finds a minimum bounding rectangle for each contour and then crops the image around each white space accordingly. In this way, documents can be found within an image file and segmented to later processing.

## Claims

### Claim 1

A method of document segmentation using artificial intelligence (AI) comprising the steps of:
receiving, by an AI system, a file comprising an image of a first document and a second document;
converting, by the AI system, the file into a tensor;
applying a deep learning model to the tensor to create a mask image from the tensor, wherein the deep learning model has been trained using a training set of images having ground truth masks and wherein each image in the training set comprises at least two documents;
converting the mask image to a grayscale image;
applying thresholding to the grayscale image to create a black and white image;
applying image processing to the black and white image to identify a first white space and a second white space along with a first contour surrounding the first white space and a second contour surrounding the second white space;
wherein the first contour comprises a first list of vectors that form a first closed shape around the first white space, and wherein the second contour comprises a second list of vectors that form a second closed shape around the second white space;
wherein the first white space has a first area the second white space has a second area;
wherein the black and white image has a total area;
comparing the first area to the total area to get a first ratio and comparing the second area to the total area to get a second ratio;
comparing the first ratio and the second ratio to a threshold value;
upon determining the first ratio exceeds the threshold value, recording the first contour;
upon determining the second ratio exceeds the threshold value, recording the second contour;
identifying a first minimum bounding rectangle that surrounds the first contour and cropping the image according to the first minimum bounding rectangle to create a first processable image; and
identifying a second minimum bounding rectangle that surrounds the second contour and cropping the image according to the second minimum bounding rectangle to create a second processable image.

### Claim 2 (depends on 1)

The method of claim 1, further comprising the step of converting the file from its original format to portable network graphics format.

### Claim 3 (depends on 1)

The method of claim 1, wherein the step of applying thresholding comprises using Otsu thresholding.

### Claim 4 (depends on 1)

The method of claim 1, wherein the step of recording the first contour comprises appending the first contour to a contour list, and wherein the step of recording the second contour comprises appending the second contour to the contour list.

### Claim 5

A method of document segmentation using artificial intelligence (AI) comprising the steps of:
receiving, by an AI system, a file comprising an image of a document;
applying a deep learning model to the file to create a mask image from the file, wherein the deep learning model has been trained using a training set of images having ground truth masks and wherein each image in the training set comprises at least two documents;
converting the mask image to a grayscale image;
applying thresholding to the grayscale image to create a black and white image;
applying image processing to the black and white image to identify a white space and a contour surrounding the white space;
wherein the white space has an area and the black and white image has a total area;
comparing the area to the total area to get a ratio;
comparing the ratio to a threshold value;
upon determining the ratio exceeds the threshold value, recording the contour; and
identifying a minimum bounding rectangle that surrounds the contour and cropping the image according to the minimum bounding rectangle to create a processable image.

### Claim 6 (depends on 5)

The method of claim 5, further comprising the step of converting the file from its original format to portable network graphics format.

### Claim 7 (depends on 5)

The method of claim 5, further comprising the step of converting the image to tensor before the step of applying a deep learning model.

### Claim 8 (depends on 5)

The method of claim 5, wherein the step of applying thresholding comprises using Otsu thresholding.

### Claim 9 (depends on 5)

The method of claim 5, wherein the step of recording the contour comprises appending the contour to a contour list.

### Claim 10 (depends on 5)

The method of claim 5, wherein the contour comprises a list of vectors that form a closed shape around the white space.

### Claim 11

A method of document segmentation using artificial intelligence (AI) comprising the steps of:
receiving, by an AI system, a file comprising an image of a first document and a second document;
applying a deep learning model to the image to facilitate converting the image into a black and white image;
identifying, in the black and white image, a first white space corresponding to the first document and a second white space corresponding to the second document;
comparing a first white space to the black and white image to create a first ratio and comparing the second white space to the black and white image to create a second ratio;
based on the first ratio, cropping the image to surround the first document; and
based on the second ratio, cropping the image to surround the second document.

### Claim 12 (depends on 11)

The method of claim 11, further comprising the step of converting the file from its original format to portable network graphics format.

### Claim 13 (depends on 11)

The method of claim 11, wherein the step of applying thresholding comprises using Otsu thresholding.

### Claim 14 (depends on 11)

The method of claim 11, wherein the deep learning model has been trained using a training set of images having ground truth masks and wherein each image in the training set comprises at least two documents.
