- #1
Leonid92
- 45
- 2
There is an original image test1.jpg. The problem is to show axes in the image and retain image quality.
I am running the following code:
1) The obtained image test2.jpg has bad quality - it became strongly pixelated.
2) The horizontal axis is bigger than the image.
I tried to use imwrite, but it doesn't save axes in image.
Please advise, how can I solve these problems.
I will be very appreciate for any help.
The original and obtained images are attached to this message.
I am running the following code:
Code:
img = imread('test1.jpg');
% define variables
imgsize1 = size(img,1); % size on screen
imgsize2 = size(img,2);
xreal = 1; % meter
yreal = 1; % meter
% create figure
figure('Position',[0,0,imgsize1,imgsize2]);
% pixel axes and actual plot
a=axes('Position',[.2 .2 .7 .7]);
set(a,'Units','normalized');
iptsetpref('ImshowAxesVisible','on');
imshow(img,'Parent',a);
% real world axis (below)
b=axes('Position',[.2 .1 .7 1e-12]);
set(b,'Units','normalized');
set(b,'Color','none');
set(b,'xlim',[0 xreal]);
% real world axis (left)
c=axes('Position',[.09 .2 1e-12 .7 ]);
set(c,'Units','normalized');
set(c,'Color','none');
set(c,'ylim',[0 yreal],'YDir','reverse');
% set labels
xlabel(a,'Pixels')
xlabel(b,'Real distance (m)')
ylabel(a,'Pixels');
ylabel(c,'Real distance (m)');
saveas(gcf,'test2.jpg');
1) The obtained image test2.jpg has bad quality - it became strongly pixelated.
2) The horizontal axis is bigger than the image.
I tried to use imwrite, but it doesn't save axes in image.
Please advise, how can I solve these problems.
I will be very appreciate for any help.
The original and obtained images are attached to this message.