matlab中的BMP2AVI程序

发布于 2024-08-28 23:59:50 字数 1243 浏览 10 评论 0原文

你好 我写了一个程序,曾经可以工作(向上帝发誓),但已经停止工作了。该代码采用一系列 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏雨凉 2024-09-04 23:59:50

BMP 图像是否有索引?我认为 map 参数仅适用于具有索引颜色图的图像。

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

过期以后 2024-09-04 23:59:50

我能够重现您收到的错误的唯一方法是当 map 是一个双元素向量,其中第一个元素大于第二个元素时。首先请注意,可以使用以下命令调用函数 IMSHOW以下语法:

imshow(I,[low high]);

其中 I 是灰度图像,lowhigh 指定像素强度的显示范围。当 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:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文