I am new to image analysis using python and am stuck with the following problem.
I have segmented images like the following: enter image description here
Using cv2.connectedcomponentswithstats I extracted the stats of the objects using the following code:
nb_components, output, stats, centroids = cv2.connectedComponentsWithStats(thresh_image, connectivity=4)
I have another table with xy coordinates and intensity values identifying point objects on the image from different channels. The table looks like the following:
Spot | x | y | target_id | intensity | quality | target_name |
---|---|---|---|---|---|---|
0 | 111.0 | 49.0 | 1 | 422.68780 | 0.519918 | Act1 |
1 | 50.0 | 132.0 | 2 | 532.04517 | 1.630690 | Tub2 |
2 | 427.0 | 141.0 | 3 | 512.33620 | 1.317758 | Ser2 |
3 | 380.0 | 171.0 | 4 | 377.43110 | 0.911759 | Pol2 |
4 | 134.0 | 190.0 | 1 | 480.68900 | 0.884888 | Act1 |
... | ... | ... | ... | ... | ... | ... |
As output I need a sparse expression matrix which basically locates each of the spots in the table to the segmented objects like the following(The table is only representative and not accurate):
Gene | Cell1 | Cell2 | Cell3 | Cell4 | ... |
---|---|---|---|---|---|
Act1 | NAN | NAN | 422.68780 | 480.68900 | ... |
Tub2 | 532.04517 | NAN | NAN | NAN | ... |
Pol2 | NAN | 377.43110 | NAN | NAN | ... |
Ser2 | NAN | 377.43110 | NAN | NAN | ... |
... | ... | ... | ... | ... | ... |
Any help/guidance will be very helpful.