Is there a simple way to obtain a table with the number of pixels for each image in a folder?
2 次查看(过去 30 天)
显示 更早的评论
I have a certain number of jpegs in a folder. I want to create a table with the title of the image, and the number of pixels in that image. Is there an easy way to do this?
0 个评论
采纳的回答
Walter Roberson
2016-11-24
No.
projectdir = 'C:\Where\The\Folder\is';
dinfo = dir( fullfile(projectdir, '*.jpg') );
num_img = length(dinfo);
img_files = {dinfo.name};
full_names = fullfile( projectdir, img_files );
img_titles = cell(num_img, 1);
num_pixel = zeros(num_img, 1);
for K = 1 : num_img
[~, img_titles{K}, ~] = fileparts( img_files{K} );
stats = imfinfo( full_names{K} );
num_pixel(K) = stats.Width * stats.Height;
end
result = table(img_titles, num_pixel, 'VariableNames', {'Title', 'NumberOfPixels'});
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!