Saving truesize images to maintain pixel resolution

4 visualizaciones (últimos 30 días)
Shant
Shant el 30 de Oct. de 2014
Respondida: Image Analyst el 30 de Oct. de 2014
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

Respuesta aceptada

Image Analyst
Image Analyst el 30 de Oct. de 2014
Don't use saveas(). Use imwrite().

Más respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by