Thread Subject: save overlay image

Subject: save overlay image

From: Oliver

Date: 18 Jul, 2011 22:02:09

Message: 1 of 4

Hi folks,

I've used the following code to display an image overlay on top of another. It works fine and I get the desired result.

------------------------------------------------
bgim = imagesc(bg);
axis off
hold on

% Overlay the image, and set the transparency previously calculated
ovly = imagesc(im);
set(ovly,'AlphaData',imAlphaData);
------------------------------------------------

I have a button in the GUI to export the image. However I'm re-plotting the images in a new figure window and using saveas, this has the drawback that it's only the resolution of the figure window and the images are actually 1504x1000. I'd like to use imwrite to output the full image as a .png but I don't know how to 'flatten' these two matrices into 1 layer. Hope that's clear enough.

Thanks in advance!

Subject: save overlay image

From: Oliver Woodford

Date: 19 Jul, 2011 11:00:26

Message: 2 of 4

"Oliver" wrote:
> Hi folks,
>
> I've used the following code to display an image overlay on top of another. It works fine and I get the desired result.
>
> ------------------------------------------------
> bgim = imagesc(bg);
> axis off
> hold on
>
> % Overlay the image, and set the transparency previously calculated
> ovly = imagesc(im);
> set(ovly,'AlphaData',imAlphaData);
> ------------------------------------------------
>
> I have a button in the GUI to export the image. However I'm re-plotting the images in a new figure window and using saveas, this has the drawback that it's only the resolution of the figure window and the images are actually 1504x1000. I'd like to use imwrite to output the full image as a .png but I don't know how to 'flatten' these two matrices into 1 layer. Hope that's clear enough.
>
> Thanks in advance!

If the two images are the same size then you can flatten them programmatically, rather than in a figure. An example of doing this is given in this answer:
http://www.mathworks.com/matlabcentral/answers/9588-multiple-colormaps-freezecolors-won-t-work
You can then use imwrite on the output.

Subject: save overlay image

From: Oliver

Date: 19 Jul, 2011 19:26:11

Message: 3 of 4

Ah you hero! that works a treat!

Now I've just got to figure out how to get a colour bar scale into the full res exported image.... I might be back with some more questions!

Subject: save overlay image

From: Oliver Woodford

Date: 20 Jul, 2011 10:41:10

Message: 4 of 4

"Oliver" wrote:
> Ah you hero! that works a treat!
>
> Now I've just got to figure out how to get a colour bar scale into the full res exported image.... I might be back with some more questions!

Have you seen SC?:
http://www.mathworks.com/matlabcentral/fileexchange/16233-sc-powerful-image-rendering
It has a couple of colormaps you might find useful for your particular problem - prob and prob_jet. Generate a figure with the image and the colorbar in, then try using export_fig:
http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig
with the -native option to get the correct image resolution.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
save Oliver 18 Jul, 2011 18:04:13
image Oliver 18 Jul, 2011 18:04:13
overlay Oliver 18 Jul, 2011 18:04:13
png Oliver 18 Jul, 2011 18:04:13
saveas Oliver 18 Jul, 2011 18:04:13
imwrite Oliver 18 Jul, 2011 18:04:13
rssFeed for this Thread

Contact us at files@mathworks.com