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:
Display transparent image in axis

Subject: Display transparent image in axis

From: Marco

Date: 14 Oct, 2008 08:15:04

Message: 1 of 3

Hi

is it possible to load an transparent image and to show in a gui which contains an axis element?

I tried

[data, map]=imread('Transparent.gif');
logo=ind2rgb(data,map);
image(logo);

or

[logo]=imread('Transparent.png');
image(logo);

but it doesn't work.

Do you have any idea? Thanks.

Subject: Display transparent image in axis

From: Jan Simon

Date: 14 Oct, 2008 09:45:04

Message: 2 of 3

Hi Marco!

> is it possible to load an transparent image and to show in a gui which contains an axis element?
>
> [data, map]=imread('Transparent.gif');
> logo=ind2rgb(data,map);
> image(logo);

If you just want to see the image with the transparent color set to the figure's background color, do exactly that! Replace the color corresponding with the transparant color in [Map].

PATCH objects can have transparent faces, so drawing a PATCH with corresponding CDATA allows even to use an ALPHAMAP, so different degrees of transparence. This is the solution if you want to see a background picture or any other objects shining through your image.

Good luck, Jan

Subject: Display transparent image in axis

From: Ida Haggstrom

Date: 24 Oct, 2008 14:22:02

Message: 3 of 3

Hi Jan!
I have a similar problem to Marco, and it seems you know quite a bit about alphamap... =)
I have used vol3d.m (http://www.mathworks.com/matlabcentral/fileexchange/4927) to render a 3d volume from a stack of 2d PET

images. The image I used was thus of size (128,128,50) where 50 is the number of slices.
Anyway, I get a nice rotatable image, but I want to alter the transparancy of individual pixels of the volume. I want to set

all pixels outside the body contour to invisible. Those pixels have index:

index = find(image(:) > 190); %image min = 0, max = 255.

I want the transparency of each pixel to be inversley proportional to the pixelvalue itself, i.e. white pixels become

transparent and black opaque. I do like this:

a = 1-image(:)/max(image(:)); % ranges from 0 to 1.
a(index) = 0;
colormap(gray)
alphamap(a);

This should make the light pixels transparant, no? It doesn't work. Do you have any idea what I'm doing wrong, and how I can

fix it? Thanks a lot!
/Ida

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <gd1pn0$gbl$1@fred.mathworks.com>...
> Hi Marco!
>
> > is it possible to load an transparent image and to show in a gui which contains an axis element?
> >
> > [data, map]=imread('Transparent.gif');
> > logo=ind2rgb(data,map);
> > image(logo);
>
> If you just want to see the image with the transparent color set to the figure's background color, do exactly that! Replace the color corresponding with the transparant color in [Map].
>
> PATCH objects can have transparent faces, so drawing a PATCH with corresponding CDATA allows even to use an ALPHAMAP, so different degrees of transparence. This is the solution if you want to see a background picture or any other objects shining through your image.
>
> Good luck, Jan

Tags for 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