I have several 700x400 images which look like image below
They consist of two regions, one represented by blue and another represented by green. These regions are separated by a line. A XML file contains 700 co-ordinates alone y-axis for the line for all images (so about 60 arrays) separating these regions which looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Data>
<Image>
<ImageUrl> file:///Data/1.tif </ImageUrl>
<Array> 150 144 169 199 199 200 210 ..... 344 </Array>
</Image>
<Image>
<ImageUrl> file:///Data/2.tif </ImageUrl>
<Array> 150 144 169 199 199 200 210 ..... 344 </Array>
</Image>
.
.
.
</Data>
Now I want to cut the image ABCD
along this line and only have the green region. I have seen this but can not get it to work. I have tried :
import xml.etree.ElementTree as ET
import cv2, numpy as np
tree = ET.parse("image.xml")
segArray = tree.findall(".//Image/Array")
arrayList = []
for i in range (0,len(segArray)-1):
xa = segArray[i].text.split(" ")
arrayList.append(xa)
arrayList = np.array(arrayList)
arrayList stores of arrays but now I can not think of a way to use these arrays to cut the image like I want to.