I want to make training images from watershed transformation output so that in each cell there will be a single image segment. How can I do this in the most efficient way?
More details: suppose L is the output of watershed segmentation:
L =
1 1 2
1 0 2
1 2 2
0 0 2
- 0 is background
- 1 is segment number 1, 2 is segment number 2 and so on.
I want to construct a cell with two images, each one contain a segment:
cell1=
1 1
1 0
1 0
cell2=
0 2
0 2
2 2
0 2
I know I can do it with some for loops and if conditions, however I need to have a solution with the best computation cost. Maybe Matlab has a bulit-in function for this task?
