Image flip around arbitrary axis
12 views (last 30 days)
Show older comments
I have a 128x128 binary mask. I would like to flip the image with respective to an arbitrary axis, similar to what 'flipup' and 'fliplr' do but with a user defined axis. Is there a quick and easy way to get this done? Thanks for reading.
0 Comments
Accepted Answer
Matt J
on 29 Aug 2017
Edited: Matt J
on 29 Aug 2017
Using AxelRot ( Download ) you could do the flip as follows given the direction vector u and a point x0 on the line in (i,j) pixel coordinates
[i,j]=find(yourMask);
ij0=[i,j].';
ij0(3,end)=0; %Embed in 3D
u(3)=0;
x0(3)=0;
ij=round(AxelRot( ij0, 180,u,x0 )).';
newMask=accumarray(ij(:,1:2),true,size(yourMask));
The above does nearest neighbor interpolation whenever the flipping places pixels at non-integer locations.
0 Comments
More Answers (0)
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!