Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to assign rgb2ind output to a reference

Subject: how to assign rgb2ind output to a reference

From: Andy Harvie

Date: 26 Mar, 2011 01:03:04

Message: 1 of 6

When you use the rgb2ind quantization technique, you end up with two outputs (x, map), which need to be shown together (imshow(x,map)).

Is there a way to assign the matrix you get when using imshow(x,map), to a name?

Thanks.

Subject: how to assign rgb2ind output to a reference

From: ImageAnalyst

Date: 26 Mar, 2011 03:05:04

Message: 2 of 6

What matrix do you get from using imshow()? From the help: "himage =
imshow(...) returns the handle to the image object created by
imshow." So you do not get a "matrix you get when using
imshow(x,map)." The handle is not really considered a matrix. It's a
scalar but I suppose you could consider it a 1 by 1 matrix if you
wanted. So you do not get a matrix when using imshow(). In fact you
"GIVE" a matrix, or two of them when using it. Please clarify your
question.

You get two matrices from rgb2ind() (*not* imshow), and of course you
can assign these to variables of any name, like
[myIndexedImage, myColorMap] = rgb2ind(rgbImage, 32);
But you of course know that because that is just standard rudimentary
computer programming.

Again, please clarify.

Subject: how to assign rgb2ind output to a reference

From: Think blue, count two.

Date: 26 Mar, 2011 04:00:58

Message: 3 of 6

On 25/03/11 8:03 PM, Andy Harvie wrote:
> When you use the rgb2ind quantization technique, you end up with two
> outputs (x, map), which need to be shown together (imshow(x,map)).
>
> Is there a way to assign the matrix you get when using imshow(x,map), to
> a name?

You would need to getframe() or the like to get the colored image.

Easier is to use the original image array; or if you used a different
color map, then ind2rgb(x,map) to get the new RGB.

Though _maybe_ what you are asking about can be answered as "You can
set() the Tag property of the image handle you get back from imshow()"

Subject: how to assign rgb2ind output to a reference

From: Andy Harvie

Date: 26 Mar, 2011 09:47:05

Message: 4 of 6

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <3dc0382d-e9dd-4836-89cb-91fc9b1ae299@a21g2000prj.googlegroups.com>...
> What matrix do you get from using imshow()? From the help: "himage =
> imshow(...) returns the handle to the image object created by
> imshow." So you do not get a "matrix you get when using
> imshow(x,map)." The handle is not really considered a matrix. It's a
> scalar but I suppose you could consider it a 1 by 1 matrix if you
> wanted. So you do not get a matrix when using imshow(). In fact you
> "GIVE" a matrix, or two of them when using it. Please clarify your
> question.
>
> You get two matrices from rgb2ind() (*not* imshow), and of course you
> can assign these to variables of any name, like
> [myIndexedImage, myColorMap] = rgb2ind(rgbImage, 32);
> But you of course know that because that is just standard rudimentary
> computer programming.
>
> Again, please clarify.

Well, now i have x and map, and when i show them both with imshow, i get the image i want. I need to find a way to assign that image made from both x and map to a single reference.

Subject: how to assign rgb2ind output to a reference

From: Andy Harvie

Date: 26 Mar, 2011 09:50:04

Message: 5 of 6

"Think blue, count two." <roberson@hushmail.com> wrote in message <%xdjp.1161$4S1.883@newsfe21.iad>...
> On 25/03/11 8:03 PM, Andy Harvie wrote:
> > When you use the rgb2ind quantization technique, you end up with two
> > outputs (x, map), which need to be shown together (imshow(x,map)).
> >
> > Is there a way to assign the matrix you get when using imshow(x,map), to
> > a name?
>
> You would need to getframe() or the like to get the colored image.
>
> Easier is to use the original image array; or if you used a different
> color map, then ind2rgb(x,map) to get the new RGB.
>
> Though _maybe_ what you are asking about can be answered as "You can
> set() the Tag property of the image handle you get back from imshow()"

That is exactly what i wanted!!!

Thanks!!!

Subject: how to assign rgb2ind output to a reference

From: ImageAnalyst

Date: 26 Mar, 2011 13:37:52

Message: 6 of 6

On Mar 26, 5:50 am, "Andy Harvie" <nightwingv...@yahoo.co.uk> wrote:
> That is exactly what i wanted!!!
>
> Thanks!!!
----------------------------------------------------------
Sorry I didn't understand your post - I guess I took it too
literally. My crystal ball or interpretive abilities are apparently
not as good as his. Down at the bottom of the rgb2ind() function you
first used, in the "See Also" section you'll see ind2rgb() - you must
have missed that. However, for some strange reason, the ind2rgb
function's help does not have rgb2ind in its "See also" section, at
least for R2010a where all it has is the "image" function. I'll try
to remember to check R2011a Monday at work and if it's still missing
in that version, I'll submit a bug report.
ImageAnalyst

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us