plotted image has low quality
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
When I tried to plot on my image and show on UIAxes, the image quality reduced significantly. It also takes too much time. However in .mlx file everything is normal.
In app Designer:

In .mlx file

Code :
s= regionprops(...)
hold on
for i =1:numel(s)
feret_diameter = s(i).MaxFeretDiameter;
if feret_diameter < 350
feret_coords = s(i).MaxFeretCoordinates;
plot(feret_coords(:, 1), feret_coords(:, 2), 'r', 'LineWidth', 2);
angle = atan2d(feret_coords(2, 2) - feret_coords(1, 2), feret_coords(2, 1) - feret_coords(1, 1));
mid_point = mean(feret_coords, 1) ;
offset_point = (mid_point + [feret_coords(2,1) feret_coords(2,2)])*0.5;
length = sqrt((feret_coords(2, 2) - feret_coords(1, 2))^2 + (feret_coords(2, 1) - feret_coords(1, 1))^2);
offset = length * 0.05;
text_position = [offset_point(1) - offset * sind(angle), offset_point(2) - offset * cosd(angle)];
text(text_position(1), text_position(2), sprintf('%.2f', feret_diameter), 'FontSize', 8, 'Rotation', -angle+180);
end
end
frame = getframe(gca);
captured_image = frame.cdata;
hold off
text(...) function also gives error like: Index in position 1 is invalid. Array indices must be positive integers or logical values.
I also used
frame = getframe(gca);
captured_image = frame.cdata;
to get quality image but it didn't help.
I need faster solution and quality image output.
Thanks for your help.
3 commentaires
Walter Roberson
le 13 Août 2023
text(...) function also gives error like: Index in position 1 is invalid
You accidentally created a variable named text at some point.
DGM
le 14 Août 2023
Modifié(e) : DGM
le 14 Août 2023
These two images were generated with the exact same code, but with different figure geometry.


Given that the relative sizes of the lines and image objects is dependent on the figure/axes geometry, then I'm going to assume that your problem stems from plotting the image in a small axes. That's just my guess. That said, we have no idea how you plotted the image or did axes setup in either case.
It's also not clear how you're capturing titles and labels using getframe() on the axes and not on the figure.
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!