How can I sort connected components from right to left and bottom to top in MATLAB? For example, I have this in the resulting label matrix L:
L = [0 0 0 1 1 1 0 0 0 0 0 3 3 0 4 4 0 0 0; ...
0 0 1 1 1 0 0 0 0 0 0 3 3 0 4 4 4 0 0; ...
0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 5 5; ...
0 0 0 0 0 0 2 2 2 2 0 0 0 0 0 0 0 5 5];
I want the connected components in an image to be read from right to left and get this in L instead:
L = [0 0 0 5 5 5 0 0 0 0 0 3 3 0 2 2 0 0 0; ...
0 0 5 5 5 0 0 0 0 0 0 3 3 0 2 2 2 0 0; ...
0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 1 1; ...
0 0 0 0 0 0 4 4 4 4 0 0 0 0 0 0 0 1 1];
I have used the regionprops function in MATLAB but it seems to work from left to right.
Have you tried rotate the binary image?