Save image in specific resolution in Matlab -


i'm trying hours output plot in specific resolution (320x240).

  xmax = 320; ymax = 240;   xmin = 0; ymin = 0;   figure;   set(gcf,'position',[1060 860 320 240]);   axis([xmin,xmax,ymin,ymax]);   plot(somelinesandpointsintherange320x240);   saveas(gca,outname,'jpg');   export_fig(outname); 

where saveas output jpg image in arbitrary resolution. export_fig still showing axes.

adding axis off or axis tight doesn't either. has idea?

update:
problem solved. completeness here current solution:

  xmax = 320; ymax = 240;   xmin = 0; ymin = 0;   figure;   set(gcf,'position',[1060 860 320 240]);   subaxis(1,1,1, 'spacing', 0.01, 'padding', 0, 'margin', 0);  % removes padding   axis([xmin,xmax,ymin,ymax]);   plot(somelinesandpointsintherange320x240);   axis([xmin,xmax,ymin,ymax]);    set(gca,'xtick',[],'ytick',[]); % removes axis notation   = frame2im(getframe(gcf)); %convert plot image (true color rgb matrix).   j = imresize(i, [240, 320], 'bicubic'); %resize image resolution 320x240   imwrite(j, 'outname.jpg'); %save image file 

possible solution converting figure image, , use imresize.

fixing figure position match 320x240 resolution possible, using imresize simpler (i think).

the following code sample, convert figure image, , use imrezie set resolution 320x240:

figure; % xmax = 320; ymax = 240; % xmin = 0; ymin = 0;   % set(gcf,'position',[1060 860 320 240]); % axis([xmin,xmax,ymin,ymax]);  plot(sin(-pi:0.01:pi)); %example figure = frame2im(getframe(gcf)); %convert plot image (true color rgb matrix). j = imresize(i, [240, 320], 'bicubic'); %resize image resolution 320x240 imwrite(j, 'j.jpg'); %save image file 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -