Image Processing on Matlab

Hi, I'm working in an engineering lab right now and I've been given a relatively simple task which I just can't get to work. My lab uses imageJ to browse through their recorded video frame by frame for some measurements. However, they've recently been running into problems where imageJ can only handle a certain number of frames and the lab's video goes well over the limit often. So my task is somehow use matlab and be able to display the data(which is in TIFF format) in real time. I saw the image sequencing manual on matlab, where the code went
%load filename
%implay(filename)
well first of all, that load command doesn't work for me for some reason. I set the directory to the folder that contains the TIFF image.
%load filename
tells me that Matlab is unable to read the file and if I try
%load 'filename.tif'
Matlab throws me this error
??? Error using ==> load Number of columns on line 1 of ASCII file C:\Documents and Settings\Administrator\Desktop\lab-track\test.tif must be the same as previous lines.
If anyone can straighten this out, I'd greatly appreciate it. Thank You
[Edit Moving comment to Question - AU]
well i tried the following code:
%fname = 'my_file_with_lots_of_images.tif';
%info = imfinfo(fname);
%num_images = numel(info);
%for k = 1:num_images
%A = imread(fname, k, 'Info', info);
%implay(A)
%end
but this only displayed the first frame on the movie player. Gahh this is so frustrating.....

답변 (2개)

Sean de Wolski
Sean de Wolski 2011년 7월 14일

0 개 추천

Perhaps try: imread()
doc imread
and maybe
doc tiff
Ashish Uthama
Ashish Uthama 2011년 7월 14일

0 개 추천

Do you just want to display the frames in sequence or is there any other reason you want to use implay?
If its just displaying, look at replacing implay with image in your code.
If you need to use implay, look at the implay(I) syntax.
[Edit: Add example - AU]
If your frames are grayscale, and each frame has the same dimensions (x by Y), then use this to create the I variable:
I=[];
for k = 1:num_images
I(:,:,k) = imread(fname, k, 'Info', info);
end
implay(I);
Depending on the number of frames (num_image). The variable I could end up being large, making the code slow. If you just wanted to perform computations, it might be faster to read in and process one/two frames at a time to keep the memory utilization low.

댓글 수: 8

Charlie
Charlie 2011년 7월 14일
I tried replacing implay with image, but it shows up as a big "mush." Basically what my lab wants to do is to track an object, which is moving, in the image file and find out the velocity. The tracking code utilizes locating a particular object in one frame and compare its position to the same object in other frame and then compare the change in coordinates and divide that by time to figure out the velocity. So there has to be some means of tracking the frames and Matlab movie player tracks frames for you, which is why I was trying to use implay in my futile attempt to display these frames. Any suggestions on how to do this?
Thank You
Charlie
Charlie 2011년 7월 14일
K in case I haven't made myself clear, this is what I wish to do:
http://www.mathworks.com/help/toolbox/images/ref/implay.html
They are using the movie player to display a sequence of images and tracking the frame number, except when I tried following it, it didn't quite work which I assume is because my format is in TIFF.
Thank You
Charlie
Charlie 2011년 7월 14일
Sorry to flood your mailbox, but this one would be better:
http://www.mathworks.com/help/toolbox/images/f10-37937.html
Ashish Uthama
Ashish Uthama 2011년 7월 14일
Updated the answer, in case you missed it.
Charlie
Charlie 2011년 7월 15일
I will try the code when I go in the lab on Monday and let you know how it goes. Thank You~!
Charlie
Charlie 2011년 7월 18일
Hey hopefully this will be the last question I have to ask you. So when I ran the code you suggested, the matlab was able to process however many frames I specify (i.e if I specify 25 frames on the for loop, Matlab will create a video with 25 frames), but the image doesn't come out right: the Matlab read the correct size but the image just comes out as complete white sheet. Any ideas?
Charlie
Charlie 2011년 7월 18일
fname = 'charlietest.tif';
info = imfinfo(fname);
I=[];
for k = 1:25
I(:,:,k) = imread(fname, k, 'Info', info);
end
implay(I)
Sean de Wolski
Sean de Wolski 2011년 7월 18일
what does
class(I)
return?
implay() prefers its data to be binary (class logical) or uint8.

댓글을 달려면 로그인하십시오.

제품

질문:

2011년 7월 14일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by