create a symmetry of an image

107 views Asked by At

Is it possible to obtain the bilateral symmetry of an binary image?

An example of the type of result that I search:

x=[true false false;false true false;false true false;false true false;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false true false;false true false;false true false;false true false;false true false;false true false;false true false;true false false];
sym=[0 0 1; 0 1 0; 0 1 0; 0 1 0; 1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0; 1 0 0;1 0 0;1 0 0;1 0 0; 0 1 0;0 1 0;0 1 0;0 1 0;0 1 0;0 1 0 ; 0 1 0;0 0 1];

figure, subplot(121), imagesc(x)
subplot(122), imagesc(sym)

enter image description here

2

There are 2 answers

0
Mac. On BEST ANSWER

As @user2999345 proposes

    % Data set
    x=[true false false;false true false;false true false;false true false;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false false true;false true false;false true false;false true false;false true false;false true false;false true false;false true false;true false false];

    % Flip array about vertical axis
    F=fliplr(x);

    figure
    subplot (121), imagesc(x)
    subplot (122), imagesc(F)
0
Siva Srinivas Kolukula On

As it is MATLAB and it is always better to learn what goes inside the functions; you can see how those functions works:

sym1 = x(:,end:-1:1) ;   % acts like fliplr, arrange columns 
sym2 = x(end:-1:1,:) ;   % acts like flipud, arrange rows