Image analysis with 688x520 images works, but same program produces nonsense for 1101x832 images

1 view (last 30 days)
Hi, I wrote a matlab program for the analysis of a folder full of images (all identical size and format). I load all images and then process them one after the other in a for loop. For 688x520 pxls images everything works well, but when I apply the program on 1101x832 pxls images, it returns different values than when I load every image individually (without the loop). Here is my code:
folder='D:\...';
%read in all images from folder
filePattern = fullfile(folder, '*.bmp');
bmpfiles=dir(filePattern);
numfiles=length(bmpfiles);
for i=1:numfiles
a{i}=importdata(bmpfiles(i).name);
end
for i=1:numfiles
% convert to gray scale
a_gray=rgb2gray(a{i});
% Rest of the image analysis
%...
%...
end;
  5 Comments
Silke
Silke on 18 Dec 2014
Yeah, that's the funny thing about it, everything works just fine on single images, but not in the loop. I noticed that something is going wrong as every twelfth object size was smaller than the others by about 10% although the object size shouldn't (or only marginally) change. That's when I had a closer look and noticed that all the values (apart from the very first one) differed. What is the function Shan? Sorry, I couldn't find it anywhere... Thanks for your help, Geoff, very much appreciated!!
Geoff Hayes
Geoff Hayes on 18 Dec 2014
Shan was a typo. If you are convinced that your code works for all single images, then you may need to post more of your code. Also, how do you call the processing on a single image? Do you gave a separate function for this?

Sign in to comment.

Answers (1)

Thorsten
Thorsten on 17 Dec 2014
Maybe there are some variables set from your first analysis. Use
clear
and rerun your second analysis.
  1 Comment
Silke
Silke on 17 Dec 2014
Hi Thorsten, thanks for the tipp. I cleared the variable for the image with clearvars, but unfortunately there was no change... Any other ideas?

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!