Hi everyone, I am having a problem with axes in gui.
2 views (last 30 days)
Show older comments
All I want to do is to remove the extra black part from the sides in the Rotated axes.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287774/image.png)
0 Comments
Answers (1)
neil jerome
on 28 Jul 2020
the black parts are created when the new rotated image is created, and so are part of the image. if you know the colour of your figure/GUI window background, you can just run the rotated image through a line that converts any added voxels into that colour. just substituting based on colour might affect genuine in-image voxels, so using a mask is safer.
this code runs for a figure, rather than a GUI, but shows the idea:
%% rotate image and 'hide' black fill from rotation
% read in colour image (use matlab example)
[I,cmp] = imread('corn.tif');
I = ind2rgb(I,cmp);
J = imrotate(I,35,'bilinear');
% convert black pixels from rotation to figure colour using mask
mask = ones(size(I));
maskrot = ceil(imrotate(mask,35, 'bilinear')); % same transform as image
figure; figCol = get(gcf, 'Color'); % get figure background colour (RGB)
maskColour = ~maskrot.*reshape(figCol, [1 1 3]);
K = J.*maskrot + maskColour;
% show
subplot(2,3,1); imshow(mask); title('mask is image size');
subplot(2,3,2); imshow(maskrot); title('rotated mask');
subplot(2,3,3); imshow(maskColour); title('applied background mask');
subplot(2,3,4); imshow(I); title('orig figure');
subplot(2,3,5); imshow(J); title('rotated figure');
subplot(2,3,6); imshow(K); title('applied background mask');
0 Comments
See Also
Categories
Find more on Subplots 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!