plotted image has low quality
2 次查看(过去 30 天)
显示 更早的评论
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
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
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 Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!