Saving truesize images to maintain pixel resolution

4 次查看(过去 30 天)
Here I go again, getting in too deep for my skill level. I am batch processing images to rename them for later processing through a different code. I was extremely pleased when my code functioned as planned, only to discover that the renamed images were scaled down in pixel size because of the saving method. This caused the second code to crash.
I have attempted to play round with saveas of an array to .jpg without displaying a gcf to no avail, as well as attempting to use the print function.
Here is the code I have, any input would be much appreciated.
%operating all pictures in a folder
clear all
close all
clc
dname_open = input('Please Enter the Directory Address of the Images:','s');
dname_save = input('Please Enter the Directory Address of the Save Destination:', 's');
%Set up basic file name path to be read
top_file = [dname_open '\'];
ls_top_file = ls(top_file);
c = cellstr(ls_top_file);
cc = c(3:length(c));
S = size(cc);
a = 1;
S(1)
%Image Opening Loop
while a<= S(1)
close all
file = char(cellstr([top_file char(cc(a))]));
data_n = char(cc(a));
file_name = char(cc(a));
imagename = (file_name);
fileToRead2 = [dname_open '\', imagename];
I = imread(fileToRead2);
imshow(I,'Border','Tight');
set(gcf, 'PaperPositionMode', 'auto');
h = gcf;
%Save function saveas(h, [dname_save '\' 'IMG_', num2str(a,'%d')], 'jpg');
a=a+1
end

采纳的回答

Image Analyst
Image Analyst 2014-10-30
Don't use saveas(). Use imwrite().

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by