Clear Filters
Clear Filters

plotted image has low quality

2 views (last 30 days)
furkan bezci
furkan bezci on 13 Aug 2023
Edited: DGM on 14 Aug 2023
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 Comments
Walter Roberson
Walter Roberson on 13 Aug 2023
text(...) function also gives error like: Index in position 1 is invalid
You accidentally created a variable named text at some point.
DGM
DGM on 14 Aug 2023
Edited: DGM on 14 Aug 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.

Sign in to comment.

Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!