Ich versuche, das Verdichtungsverhältnis zu berechnen, sondern die Handlung zurückkehrt mir ein leeres Fenster, Es ist gut, früher zu arbeiten, aber jetzt weiß ich nicht, was ist das Problem hier ist mein CodeGrundstück zurückkehrt mir ein leeres Fenster
function goodCompressionLevel = findGoodCompressionLevel(targetRatio, filename)
width = 672;
height = 380;
for compressionLevel = 1:255
[~,~,ext] = fileparts(filename);
if strcmp(ext, '.db') ~= 1
originalFileSize = 8*width*height;
[~,name,~] = fileparts(filename);
output = strcat(name, '_temp.jxr');
system(['/usr/local/Cellar/jxrlib/1.1/bin/JxrEncApp -i ' filename ' -o ' output ' -q ' num2str(compressionLevel)]);
fileInfo = dir(output);
newFileSize = fileInfo.bytes;
ratios(compressionLevel+1) = originalFileSize/newFileSize;
fprintf('Current Ratio: %d\n', ratios(compressionLevel+1));
%delete(output);
end
end
plot(ratios);
minDist = Inf;
for r = 1:length(ratios)
display(abs((ratios(r) - targetRatio)));
display(minDist);
if abs((ratios(r) - targetRatio)) <= minDist
minDist = abs((ratios(r) - targetRatio));
else
goodCompressionLevel = r-1;
display(goodCompressionLevel);
break;
end
end
end
Könnten Sie mir bitte helfen, es zu beheben?
Untersuchen Sie den Inhalt von "Ratio", ohne es zu zeichnen. Ist es leer? Ist es voll von NaNs? – Peter