Batch processing images to average pixel values- blank output
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Shant
am 29 Okt. 2014
Kommentiert: Shant
am 29 Okt. 2014
After much help from the community on here, and some minor tweaking I finally have a code for batch processing images for an averaged image. It seems like the entire code is functioning properly except for the final output. The output should be an average of all images in the folder selected, however it is outputting a blank white image rather than an averaged image. I have checked the arrays, and the arrays hold proper averaged pixel values for the batch of images. Which leads me to my question.... Why won't this code output a proper averaged image?
clc;
clear all;
close all;
% User selecting image directory
cd(uigetdir);
% Counting number of .JPG's in folder
Files = dir('*.jpg');
b=numel(Files);
% Initialize to first image.
I0 = imread('IMG_1.jpg')
sumImage = double(I0);
% Read in remaining images.
for i=2:b
rgbImage = imread(['IMG_',num2str(i),'.jpg']);
sumImage = sumImage + double(rgbImage);
end;
% Average Image and output file
meanImage = sumImage / b
imshow(meanImage);
imshow(meanImage,'Border','Tight');
set(gcf, 'PaperPositionMode', 'auto');
h = gcf;
saveas(h, [cd '\' 'IMG_Average'], 'jpg');
As you can see in the following picture, the array shows pixel values, but the figure is blank
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!