matlab中的BMP2AVI程序
你好 我写了一个程序,曾经可以工作(向上帝发誓),但已经停止工作了。该代码采用一系列 BMP 并将它们转换为 avi 文件。这是代码:
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
这是我得到的错误:
??? 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);
出于某种原因,我不能将其作为代码段。抱歉,
谢谢你,
阿里尔
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
BMP 图像是否有索引?我认为
map
参数仅适用于具有索引颜色图的图像。Are the BMP images indexed? I think the
map
parameter only applies to images with indexed color maps.我能够重现您收到的错误的唯一方法是当
map
是一个双元素向量,其中第一个元素大于第二个元素时。首先请注意,可以使用以下命令调用函数 IMSHOW以下语法:其中
I
是灰度图像,low
和high
指定像素强度的显示范围。当I
是 RGB 图像时,额外的参数将被忽略,但即使如此,high
的值也必须大于low
的值或抛出错误(您在上面看到的错误)。令人困惑的是为什么
map
是一个二元素向量。使用 IMREAD 加载图像时,map
输出要么为空(如果图像不是索引图像),要么是 N×3 颜色图。我无法想到内置 IMREAD 的情况 将返回一个仅包含 2 个元素的map
参数。基于您所说的事实,它曾经工作,但现在突然不行了,我建议您首先检查一下您是否无意中在某处创建了一个名为
imread< 的 m 文件/代码>。这样做可能会导致调用新的
imread
函数而不是内置函数,从而产生与预期不同的输出。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:In which
I
is a grayscale image andlow
andhigh
specify the display range for the pixel intensities. The extra argument is ignored whenI
is an RGB image, but even then the value ofhigh
must be greater than the value oflow
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, themap
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 amap
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 newimread
function to be called instead of the built-in one, giving you different outputs than you expect.