Hi everyone, I am having a problem with axes in gui.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
neil jerome
2020년 7월 28일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!