A computer-implemented method comprising: receiving a document image ; analyzing pixels of the document image using a neural network to identify characters (205A-C, 215, 225, 235, 245) of the document image and formatting of the characters (205A-C, 215, 225, 235, 245); assigning index values (210A-D, 220A-B) to identified characters (205A-C, 215, 225, 235, 245), wherein different index values (210A-D, 220A-B) are identified for different character (205A-C, 215, 225, 235, 245) formatting; identifying a background class which refers to the background of the document image and distinguishing the index values (210A-D, 220A-B) from the background; generating a first segmentation mask using the neural network and masking a first subset of identified characters (205A-C, 215, 225, 235, 245) using the index values (210A-D, 220A-B), wherein index values (210A-D, 220A-B) replace the pixel area occupied by the characters (205A-C, 215, 225, 235, 245), and wherein the index values (210A-D, 220A-B) are combined along with the background class; generating a second segmentation mask using the neural network and masking a second subset of characters (205A-C, 215, 225, 235, 245) of the document image using the index values (210A-D, 220A-B), wherein index values (210A-D, 220A-B) replace the pixel area occupied by the characters (205A-C, 215, 225, 235, 245), wherein the index values (210A-D, 220A-B) are combined along with the background class, and wherein the formatting of the first subset of characters (205A-C, 215, 225, 235, 245) differs from the formatting of the second subset of characters (205A-C, 215, 225, 235, 245); supplying the first segmentation mask and the second segmentation mask to a document processing system; and performing additional processing on the document image by the document processing system based on the first segmentation mask and the second segmentation mask . receiving a document image ; analyzing pixels of the document image using a neural network to identify characters (205A-C, 215, 225, 235, 245) of the document image and formatting of the characters (205A-C, 215, 225, 235, 245); assigning index values (210A-D, 220A-B) to identified characters (205A-C, 215, 225, 235, 245), wherein different index values (210A-D, 220A-B) are identified for different character (205A-C, 215, 225, 235, 245) formatting; identifying a background class which refers to the background of the document image and distinguishing the index values (210A-D, 220A-B) from the background; generating a first segmentation mask using the neural network and masking a first subset of identified characters (205A-C, 215, 225, 235, 245) using the index values (210A-D, 220A-B), wherein index values (210A-D, 220A-B) replace the pixel area occupied by the characters (205A-C, 215, 225, 235, 245), and wherein the index values (210A-D, 220A-B) are combined along with the background class; generating a second segmentation mask using the neural network and masking a second subset of characters (205A-C, 215, 225, 235, 245) of the document image using the index values (210A-D, 220A-B), wherein index values (210A-D, 220A-B) replace the pixel area occupied by the characters (205A-C, 215, 225, 235, 245), wherein the index values (210A-D, 220A-B) are combined along with the background class, and wherein the formatting of the first subset of characters (205A-C, 215, 225, 235, 245) differs from the formatting of the second subset of characters (205A-C, 215, 225, 235, 245); supplying the first segmentation mask and the second segmentation mask to a document processing system; and performing additional processing on the document image by the document processing system based on the first segmentation mask and the second segmentation mask . <EOS>