Why are plot titles assigned differently in Windows and MacOS?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dennis Mueller
le 22 Oct 2024
Modifié(e) : Bruno Luong
le 22 Oct 2024
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 commentaires
Réponse acceptée
Bruno Luong
le 22 Oct 2024
Modifié(e) : Bruno Luong
le 22 Oct 2024
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 commentaires
Bruno Luong
le 22 Oct 2024
Modifié(e) : Bruno Luong
le 22 Oct 2024
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks 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!