Why are plot titles assigned differently in Windows and MacOS?
5 次查看(过去 30 天)
显示 更早的评论
Hello,
the following behaviour has been observed running a script for demonstration of a simple iterative CT reconstruction:
In windows, all plot titles are displayed correctly. However, in macOS, some titles are assigned to the previous plot. This has been tested with two different machines (mac Studio and Macbook Air) in two different MATLAB versions (2024b, 2023b).
The behaviour should be reproducible with the following code (running here in browser creates the correct titles):
% Short demo script for iterative reconstruction of a ct image
clearvars;
close all;
ctImage= phantom('Modified Shepp-Logan',256);
figure()
imshow(ctImage)
title("Original Image")
sinogram = radon(ctImage);
[reconstructionLines, projectionAngles] = size(sinogram);
figure()
imshow(sinogram/max(sinogram, [], "all"))
title("Sinogram")
% Iterative reconstruction algorithm
numberOfReconstructionSteps = 180;
angleStepSize = 180/numberOfReconstructionSteps;
tempDifference = zeros(reconstructionLines, 1);
iterativeReconstruction = zeros(reconstructionLines, reconstructionLines);
for i = 1:reconstructionLines
iterativeReconstruction(i,:) = sinogram(i,angleStepSize)/reconstructionLines;
end
figure()
imshow(iterativeReconstruction/max(iterativeReconstruction, [], "all"))
title("First projection")
for i = 1:numberOfReconstructionSteps
iterativeReconstruction = imrotate(iterativeReconstruction, angleStepSize, "bicubic", "crop");
for j = 1:reconstructionLines
tempDifference(j) = sinogram(j,i) - sum(iterativeReconstruction(:,j));
iterativeReconstruction(:,j) = iterativeReconstruction(:,j) + tempDifference(j)/reconstructionLines;
end
figure(4)
imshow(iterativeReconstruction/max(iterativeReconstruction,[],"all"))
end
% Show result and compare to reconstruction by inverse radon transform
figure()
imshow(iterativeReconstruction)
title("Iterative reconstructed image")
reconstructedImage = iradon(sinogram, 0:179);
figure()
imshow(reconstructedImage/max(reconstructedImage, [], "all"))
title("Reconstruction by inverse Radon transform")
The titles i am getting in macOS are:
figure 1: correct title
figure 2: title of figure 3
figure 3 + 4 no title (4 has no title, 3 should have one)
figure 5: title of figure 6
figure 6: no title (there is no figure 7, which could be the title if there were more figures)
0 个评论
采纳的回答
Bruno Luong
2024-10-22
编辑:Bruno Luong
2024-10-22
Regardless the platform, use graphic handles to be sure where the title (or any graphic object) correctly appears. As example
figh = figure();
axh = axes(figh);
imshow(axh, iterativeReconstruction)
title(axh, "Iterative reconstructed image")
2 个评论
Bruno Luong
2024-10-22
编辑:Bruno Luong
2024-10-22
My guess is that on Mac OS the creation of figure/axes are somewhat asynchronuous and the current object has not been updated internally when you inhvoke title, and it instead appears on an old axes
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!