TIF文件的尺寸为"420x560x3". -Matlab到IDL [英] Dimension of a TIF file as "420x560x3" - Matlab to IDL

查看:234
本文介绍了TIF文件的尺寸为"420x560x3". -Matlab到IDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VideoWriter功能下的一系列功能在Matlab中创建电影.我的代码有点像下面所示的代码:

I am trying to create a movie in Matlab using series of functions under VideoWriter function. My code is somewhat like one shown below:

vidObj=VideoWriter('movie.avi');
open(vidObj);

for i=1:N %N is number of frames

[nx,ny]=coordinates(Lx,Ly,Nx,Ny,[x(i),-y(i)]);
%Lx and Ly refer to the length and height in meters. 
%Nx and Ny are number of pixels (boxes) and fit into the respective L's. 
%If Lx=10e-6 , with Nx=5, there will be 5 pixels in x dimension,
%each of length 2e-6 m.
[xf,yf]=ndgrid(nx,ny);
zf=zeros(size(xf))+z(i);    

% generate a frame here
[E,H]=nfmie(an,bn,xf,yf,zf,rad,ns,nm,lambda,tf_flag,cc_flag);
Ecc=sqrt(real(E(:,:,1)).^2+real(E(:,:,2)).^2+real(E(:,:,3)).^2+imag(E(:,:,1)).^2+imag(E(:,:,2)).^2+imag(E(:,:,3)).^2);
clf
imagesc(nx/rad,ny/rad,Ecc)
rectangle('Position',[-rad(end),-rad(end),dia(end),dia(end)],'Curvature',[1,1]);
axis image;
axis off;
currFrame=getframe(gcf);
writeVideo(vidObj,currFrame);
end
close(vidObj);
return

这产生了一部名为movie.avi的电影.但是,电影(以及从命令窗口生成的tif图像)的尺寸为"420x560x3".

This generated a movie called movie.avi. However, the movie (and the tif images generated from command window) has the dimensions of "420x560x3".

tif是使用以下代码从movie.avi生成的:

edit: the tif's are generated from the movie.avi using the following code:

obj = VideoReader('movie.avi');
vid = read(obj);
frames = obj.NumberOfFrames;
for x = 1 : frames
    imwrite(vid(:,:,:,x),strcat('frame-',num2str(x),'.tif'));
end

我正尝试在其他软件IDL中使用以下图像: 阅读此链接的第1部分

I am trying to use these images in another software, IDL, following: read Part 1 of this link

但是,当在IDL上运行时,它将尺寸检测为[3x420x560],因此在运行规范化时会生成一个非常奇怪的图像.

However, when runs on IDL, it detects the dimensions as [3x420x560], and therefore generates a really weird image when I run the normalization.

  1. 我该如何解决?使用imwrite会有所帮助吗?
  2. 我能够在IDL中成功打开.tif,但它表明420x560实际上是包含外部灰色边界的图像.

如何删除此边界?我试着看我的功能,它们很好. (我认为)

How do I remove this boundary? I tried seeing through my functions and they were fine. (I think)

我提前问了这么多问题表示歉意.我对此很陌生,需要帮助.再次谢谢你

I apologize in advance for asking so many questions. I am very new to this and need help. Thank you once again

推荐答案

我认为您图像周围的灰色边界是由于以下事实:当代码抓住帧(使用getframe)时,该帧已通过了句柄到当前图形(gcf),其中包括图像周围的灰色边界.尝试改用当前轴的手柄

I think that the grey boundary around your image is due to the fact that when the code grabs the frame (using getframe) it is being passed the handle to the current figure (gcf) which includes the grey boundary around the image. Try instead using the handle to the current axis

currFrame=getframe(gca);

我尝试了这个,并且使用gca尝试

I tried this and with gca there was no grey boundary around the image when I tried the

image(currFrame.cdata);

检索框架时,其中对应于图像的数据的尺寸减小了.我不确定为什么代码会执行此操作,但是getframe的替代方法是执行以下操作

When I retrieved the frame, the data within that corresponded to the image was reduced in dimension. I'm not sure why the code does this but an alternative to getframe is to do the following

I           = imread('someImage.jpg');
h           = imagesc(I);
imageScData = get(h,'CData');
frameData   = im2frame(imageScData);

自然地,您将没有前两行,因为您是在for循环的每次迭代中构建图像的.但是我确实注意到了size(frameData.cdata)==size(I)-所以没有减少.

Naturally, you won't have the first two lines since you are building your image at each iteration of the for loop. But I did notice that size(frameData.cdata)==size(I) - so no reduction.

您还提到了IDL(我从未使用过)如何错误地读取文件,或者错误地检测了图像尺寸.您如何将图像写到tif文件中? (我没有在上面看到任何MATLAB代码,例如imwrite表示这一点.)

You also mention how IDL (which I've never used) is reading in the files incorrectly or rather that the image dimensions are detected incorrectly. How are you writing out the image to a tif file? (I didn't see any MATLAB code above, like imwrite, indicating this.)

这篇关于TIF文件的尺寸为"420x560x3". -Matlab到IDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆