plotted image has low quality

2 次查看(过去 30 天)
furkan bezci
furkan bezci 2023-8-13
编辑: DGM 2023-8-14
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 个评论
Walter Roberson
Walter Roberson 2023-8-13
text(...) function also gives error like: Index in position 1 is invalid
You accidentally created a variable named text at some point.
DGM
DGM 2023-8-14
编辑:DGM 2023-8-14
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by