InsightSoftwareConsortium/ITKMontage

How to generate TileConfiguration.txt.

kuldeep203 opened this issue · 4 comments

I am working on digital microscopy for whole slide imaging. i am capturing lots of images and at last i need to stitch all of them to create a single image. i was trying your python example but dont know how to create TileConfiguration.txt. Can you help me in that case.

This is somewhat a duplicate of #208. If you don't want to create TileConfiguration.txt by hand, you could use Image Stitching Plugin for Fiji to create it.

the origin is at the top-left corner, suppose the motor moves like this

↓  ↑→ ↓
↓  ↑  ↓
↓→ ↑  ↓

got pictures as below

000_000.jpg  001_002.jpg  002_000.jpg
000_001.jpg  001_001.jpg  002_001.jpg
000_002.jpg  001_000.jpg  002_002.jpg

(1-overlap_ratio)*height=h_offset is vertical expect offset
(1-overlap_ratio)*width=w_offset is horizontal expect offset

the TileConfiguration.txt should be like this

dim = 2
000_000.jpg;;(0, 0)
001_002.jpg;;(1*w_offset , 0)
002_000.jpg;;(2*w_offset , 0)
000_001.jpg;;(0, 1*h_offset )
001_001.jpg;;(1*w_offset, 1*h_offset )
002_001.jpg;;(2*w_offset, 1*h_offset )
000_002.jpg;;(0, 2*h_offset )
001_000.jpg;;(1*w_offset, 2*h_offset )
002_002.jpg;;(2*w_offset, 2*h_offset )

you can search the key word in issues, maybe you can find similiar questions like this one, or mock the examples it has mentioned, it will save yourself a lots of time

For 2D stitching, if you have the starting XY positions for the tiles, I think the following code should arrange them as needed for TileConfiguration.txt

Provided you have x increasing from left to right, and y increasing from top to bottom. One tile should be at (0, 0) which will be top left corner.

x_positions = xy_positions[:,0]
y_positions = xy_positions[:,1]

sorted_indices = np.lexsort((x_positions, y_positions))
xy_positions_sorted = xy_positions.take(tuple(sorted_indices), axis=0)

Reopen the issue if there are further details.