Here is my code:
F= aviread('xy.avi',1);
[X,map]=frame2im(F);
RGB = ind2rgb(X,map);
image(X);
image(RGB);
But it causes error message:
??? Index exceeds matrix dimensions.
Error in ==> ind2rgb at 27
r = zeros(size(a)); r(:) = cm(a,1);
It's obvious that [X,map] produce empty 'map' in this case
and it might cause the error message. So,how can I get /add
colormap for indexed image with empty 'map' variable?
Thanks
It looks like you are not getting back an indexed image from aviread,
but instead are getting a true color image.
What is the result of running 'size(X)' after you call frame2im?
-Dave Tarkowski
Result is:
size(X)
ans =
240 320 3
I'm still trying to get (256 gray) intensity image from the
original RGB image.
Thanks
VN
Okay, so X is a truecolor RGB image. There are a number of ways to
convert an RGB image to a grayscalse image. If you own the Image
Processing Toolbox, the easiest would be to use the rgb2gray function.
-Dave