Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ind2rgb

65 views
Skip to first unread message

Vojtech Nemec

unread,
Feb 21, 2008, 4:25:04 AM2/21/08
to
Hi,
I would like to convert indexed image to rgb image retrieved
from avi (true color) movie to compare some consequent image
processing methods...

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

Dave Tarkowski

unread,
Feb 21, 2008, 9:59:16 AM2/21/08
to

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

Vojtech Nemec

unread,
Feb 21, 2008, 10:11:02 AM2/21/08
to
Dave Tarkowski <dave.ta...@mathworks.com> wrote in
message <fpk3k4$gpf$1...@fred.mathworks.com>...

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


Dave Tarkowski

unread,
Feb 21, 2008, 1:42:39 PM2/21/08
to

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

0 new messages