Image analysis with 688x520 images works, but same program produces nonsense for 1101x832 images
Mostrar comentarios más antiguos
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 comentarios
Geoff Hayes
el 17 de Dic. de 2014
Silke - can you elaborate on what you mean by produces nonsense and it returns different values? Do you call the image analysis code on an individual grayscale image (so you have done the conversion with rgb2gray) or do you do it some other way?
Try stepping through the code by putting a breakpoint at the line a_gray=rgb2gray(a{i});. What are the dimensions of a_gray? Does it make sense?
Silke
el 17 de Dic. de 2014
Geoff Hayes
el 18 de Dic. de 2014
Editada: Geoff Hayes
el 18 de Dic. de 2014
There must be a problem with your image analysis function. Is there some dependency on the smaller image dimensions? In the larger images, is the object that you are trying to size bigger, smaller, or the same size as in the original image? Does the nonsense values give you a size that is bigger or smaller than the actual size of the image, and is this consistent across all of the larger images?
But then you are saying that if you run the code on a single large image it works fine. Is this correct? What happens if you run the function on another large image - is the object size correct or not?
Silke
el 18 de Dic. de 2014
Geoff Hayes
el 18 de Dic. de 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?
Respuestas (1)
Categorías
Más información sobre Image Arithmetic en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!