plotted image has low quality

조회 수: 4 (최근 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개)

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by