MATLAB: How to save high resolution image with original size and quality

dpngimageImage Processing Toolboximshowlarge imagepaperpositionpaperunitsprintresolutionsaveasscreenpixelsperinch

Hi,
I'm trying to save a high resolution image (trial.png) that I load into a figure and edit (modify some pixels).
The code is:
hread=imread([fname]);
[height,width,dim]=size(hread);
res = get(0,'screenpixelsperinch');
% for keeping original image size
set(gcf, 'PaperUnits', 'inches', 'PaperPosition', [0 0 width height]/res);
% for margin removal
horg = get(gca,'position')
set(gca,'position',[0 0 1 1],'units','normalized')
dirname = dir;
filename = fn;
print(gcf,'-dpng', '-noui',fullfile(dir,fn),['-r' num2str(res)])
When I save the image either using print or export_fig (export_fig_out.png), image resolution comes out the same however image looks very pixelated.
How do I make sure image is saved with the properties of the native image?
Thanks

Best Answer

Hello,
I believe I found a way. Based on Rik's and Image Analyst's answers I had to rewrite some portion of my code to use the following commands to get the job done directly on the image matrix:
-InsertMarker
-InsertShape
-InsertText
Thanks!