tags:

views:

85

answers:

2

HI I wrote a program that use to work (swear to god) and has stopped from working. this code takes a series of BMPs and convert them into avi file. this is the code:

path4avi='C:/FadeOutMask/'; %dont forget the '/' in the end of the path
pathOfFrames='C:/FadeOutMask/';
NumberOfFiles=1;
NumberOfFrames=10;

%1:1:(NumberOfFiles)
for i=0:1:(NumberOfFiles-1)
FileName=strcat(path4avi,'FadeMaskAsael',int2str(i),'.avi') %the generated file
aviobj = avifile(FileName,'compression','None'); 
aviobj.fps=10;

    for j=0:1:(NumberOfFrames-1)
    Frame=strcat(pathOfFrames,'MaskFade',int2str(i*10+j),'.bmp') %not a good name for thedirectory
    [Fa,map]=imread(Frame);
    imshow(Fa,map);
    F=getframe();
    aviobj=addframe(aviobj,F)
    end
aviobj=close(aviobj);
end    

And this is the error I get:

??? Error using ==> checkDisplayRange at 22
HIGH must be greater than LOW.

Error in ==> imageDisplayValidateParams at 57
common_args.DisplayRange = checkDisplayRange(common_args.DisplayRange,mfilename);

Error in ==> imageDisplayParseInputs at 79
common_args = imageDisplayValidateParams(common_args);

Error in ==> imshow at 199
  [common_args,specific_args] = ...

Error in ==> ConverterDosenWorkd at 19
    imshow(Fa,map);

for some reason I cant put it as code segments. sorry

thank you

Ariel

A: 

Are the BMP images indexed? I think the map parameter only applies to images with indexed color maps.

mtrw
I don't know. How do i check it? is there a matlab\python operation that indexes the images?
ariel
I don't do much image processing, but my understanding is that indexing refers to a way of storing the color data. See http://en.wikipedia.org/wiki/Indexed_color for more information. I have no idea if `imread` will have a problem if you ask for a `map` parameter when the file doesn't have one. I guess you could create an image file with Paint or the GIMP or something and verify that `imread` behaves like you expect.
mtrw
A: 

The only way I am able to reproduce the error that you get is when map is a two-element vector where the first element is greater than the second. Note first that the function IMSHOW can be called with the following syntax:

imshow(I,[low high]);

In which I is a grayscale image and low and high specify the display range for the pixel intensities. The extra argument is ignored when I is an RGB image, but even then the value of high must be greater than the value of low or an error is thrown (the one you see above).

What's confusing is why map would be a two-element vector. When loading an image with IMREAD, the map output will either be empty (if the image is not an indexed image) or it will be an N-by-3 color map. I can't think of a situation where the built-in IMREAD would return a map argument with just 2 elements.

Based on the fact that you said it was working, and now suddenly isn't, I would suggest first checking to see if you have inadvertently created an m-file somewhere with the name imread. Doing so could cause that new imread function to be called instead of the built-in one, giving you different outputs than you expect.

gnovice

related questions