Hi everyone, I am having a problem with axes in gui.

2 vues (au cours des 30 derniers jours)
Ahsan Malik
Ahsan Malik le 26 Avr 2020
All I want to do is to remove the extra black part from the sides in the Rotated axes.

Réponses (1)

neil jerome
neil jerome le 28 Juil 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');

Catégories

En savoir plus sur 3-D Scene Control dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by