Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Overlay image on a plot, with transparent background on image
Date: Tue, 27 Jan 2009 19:53:03 +0000 (UTC)
Organization: Queen's University
Lines: 10
Message-ID: <glnomv$qe$1@fred.mathworks.com>
References: <glnh6v$oao$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1233085983 846 172.30.248.38 (27 Jan 2009 19:53:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 27 Jan 2009 19:53:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 943450
Xref: news.mathworks.com comp.soft-sys.matlab:514340


I've never tried to use image transparencies in MATLAB, so I don't know how to solve it that way.  Can you do it the other way around - patch plot on top of the image?

imshow(im, []);
h = patch([10, 200, 200], [10, 10, 200], [1, 0 0]);
set(h, 'FaceAlpha', .4, 'EdgeColor', 'none');

If that means your patch vertices would have to be too accurate, you could load in a simple black and white image, use bwtraceboundary or bwboundaries to get the coordinates of the borders, and plot them on top using line.  The image is then only used to get the coordinates, you don't actually display it.  This would also give you control over how thick you want the borders to display and it could scale more nicely.

The 'tracing object boundaries' part here might help:
http://www.mathworks.com/access/helpdesk/help/toolbox/images/index.html?/access/helpdesk/help/toolbox/images/f11-11942.html