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
0 件のコメント
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!