Code covered by the BSD License  

Highlights from
SC - powerful image rendering

4.89286

4.9 | 28 ratings Rate this file 132 Downloads (last 30 days) File Size: 41.8 KB File ID: #16233
image thumbnail

SC - powerful image rendering

by

 

04 Sep 2007 (Updated )

Useful tool for rendering and outputting information rich images

| Watch this File

File Information
Description

SC is a useful function for displaying rich image data, of use to anyone wishing to visualize and save 2D data in ways beyond that which MATLAB built-in functions allow.

This function can be used in place of IMAGE, IMAGESC and IMSHOW, but does so much more. It is fast and displays images as they should be - correct aspect ratio, integer magnification, no axes. In addition, it can return the image as an output variable - useful for saving to disk, texture mapping surfaces, and post-rendering manipulation such as overlaying/combining two or more images.

All the MATLAB built-in colormaps are implemented, but without MATLAB's nasty discretization artifacts. Plus, there are many new colormaps which are helpful for viewing more complex data, such as optic flow, likelihoods over images, difference images, segmentations, stereo image pairs (as anaglyphs) and edge-maps with orientation. It also accepts user defined linear and non-linear colormaps.

SC comes with a complete demo, to help you get the most out of it. It doesn't require that you have any toolboxes, either.

SC makes heavy use of two of my other file exchange packages, IMDISP (id 22387) and REAL2RGB (id 23342), which are both included in this package, but are very useful in their own rights too.

Please send queries or bug reports direct to me using the "Contact Author" link on my Author page.

Acknowledgements

Imdisp and Real2rgb & Colormaps inspired this file.

This file inspired Zerocolor.

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (54)
17 Mar 2014 TJ  
05 Feb 2014 Oliver Woodford

Javier: Both the help text and the demo provide the answer -
>> help sc
>> sc
This is what you want to use -
>> sc(cat(3, likelihood_img, img), 'prob')

05 Feb 2014 Javier Montoya

Hi Oliver, great work! I was wondering if you could give some examples on how to overlay likelihoods (MxMx1) into an RGB image (MxMx3). I tried something like: sc(img,cat(3,likelihood_img,likelihood_img,likelihood_img));
But didn't work out. Ideally, the output should look something like in the top-right figure of your webpage (Eli's example using `prob` and `probjet`): http://www.robots.ox.ac.uk/~ojw/software.htm
Thank you!

28 May 2013 Oliver Woodford

Abbas: The comments box is not the place for questions. Note that sc() and imsc() can take multiple masks, e.g.:
>> Z = peaks(256);
>> imsc(Z, 'jet', [0 0 0.5], Z>0&Z<0.2, [0 0 0.7], Z<-0.1&Z>-0.3);

28 May 2013 Abbas

Dear Oliver

I have the digital elevation map of a region (dem1) and I am trying to flow two rivers with the codes of 1 and 0.5 in a new matrix named WetrSurf and overlay the WetSurf on dem1 to show the water flowing from two streams. It is possible to show one river but not for two:
When I have:
imsc(dem1,'jet',[0 0 128/255],(WetSurf==1));axis equal;axis image;axis ij;
title(['Flood Inundation: Iter = ' num2str(k) ', W-Lev = '...
num2str(WLE) 'm'],'FontSize',16);
It beautifully works but when I want to show those arrays of WetSurf with the value of 0.5 in the same image I will have problem. Please let me know how I can superimpose the second values of WetSurf (0.5) on the same topograpgy(dem1) simultaneously? Maybe I need to combine the following lines but I cant:

imsc(dem1,'jet',[0 0 128/255],(WetSurf==1));axis equal;axis image;axis ij;
title(['Flood Inundation: Iter = ' num2str(k) ', W-Lev = '...
num2str(WLE) 'm'],'FontSize',16);

imsc(dem1,'jet',[0 0 128/255],(WetSurf==0.5));axis equal;axis image;axis ij;
title(['Flood Inundation: Iter = ' num2str(k) ', W-Lev = '...
num2str(WLE) 'm'],'FontSize',16);
pause(0.1);

Best regards
Abbas

10 Apr 2013 Julia

Terrific

29 Jun 2012 SHAFIQUL  
02 May 2012 bella  
25 Apr 2012 Tao Han  
07 Mar 2012 Oliver Woodford

Matthias: You can achieve that by setting the CurrentAxes property of the figure directly before calling SC. Alternatively, you can first draw the image in your GUI using IMAGE and save the image handle, then in the callbacks just set the CData property of the image using the output of SC. I do the latter, because it is faster at updating on screen.

07 Mar 2012 Matthias Geissbuehler

Very nice framework! Works like a charm!
A little request which would make it even more useful: I would like to tell sc which axes-handle to use -> I would like to use it inside a GUI. is something like this imaginable? Or is sc not going to have enough flexibility in such a manner, since the axis position (&size) are going to be fixed? Any thoughts on this?

05 Jan 2012 Salmah Yasiran

Nice one!!

11 Nov 2011 Fabian  
16 Aug 2011 Rafa  
09 Aug 2011 Magnus

This is something of a stretch, but have you considered adding support for displaying CMYK-images? Otherwise, I love this function

18 Jul 2011 Oliver Woodford

bmv: This is a problem with lipsol - any MATLAB function should be able to cope with the possibility sharing variable names with the names of functions on the path. I suggest you email the author, or fix it yourself.

30 Jun 2011 bmv

The name sc clashes with the Matlab file:

??? Error: File: lipsol.m Line: 987 Column: 7
"sc" previously appeared to be used as a function or command, conflicting with its use here as the name
of a variable.
A possible cause of this error is that you forgot to initialize the
variable, or you have initialized it implicitly using load or eval.

26 May 2011 Harald Mayr  
25 May 2011 Qianqian

Sorry, I have seen all the demos. This is a great tool.

25 May 2011 Qianqian

This is great. Just what I want. Would you please post an example here, which will make things easier for the user? Thank you very much. :)

28 Feb 2011 Oliver Woodford

A note to all: SC only fills the figure completely with an image if the current axes is the default size. Therefore to avoid this behaviour, change the size of the axes first, e.g.:
set(gca, 'Position', [0.1 0.1 0.8 0.8]);
sc(peaks(128));

28 Feb 2011 Brent Boehlert

Oliver: I sent you an email with an example. Let me know if you didn't receive it and I'll post it here.

26 Feb 2011 Oliver Woodford

Brent: For help on this, please email me with an example figure and and print command.

26 Feb 2011 Brent Boehlert

Hello Oliver,
Excellent work on this function. I have one issue -- when I print a figure to a .tif or .pdf, the colorbar labels on the right don't show up. If I move the outerposition of the figure over, they do, but then the left side of the image is cut off. Any thoughts on how to get the colorbar labels on my printed figure?

13 Jan 2011 Oliver Woodford

Camille: I think it's unlikely.

22 Dec 2010 Camille Couzi

Hi, I left a message and it wasn't saved...
I sthat possible that nexplot property with replacechildren argument don't work for the same reason as the one told by Dove (and your answer about RGB images...)

05 Dec 2010 Oliver Woodford

Dove: CAXIS only works on indexed images. The images generated by SC are RGB images (for various good reasons). There is an alternative - specify the range bounds in the call to SC. It's in the help text ("limits" argument).

05 Dec 2010 Dove

Hi Oliver,

I found that caxis is not working. Is there an alternative?

03 Nov 2010 Oliver Woodford

Camille: No. The tick functionality is the same as that of image. I suggest you contact the author of that submission to request support for images.

02 Nov 2010 Camille Couzi

Hi! Is that possible to fix dateticks on this kind of image? I would need to apply dynamic date ticks (see http://www.mathworks.com/matlabcentral/fileexchange/27075-intelligent-dynamic-date-ticks, wich works on plot, but apparently not on imagesc and sc...
Thanks for reply!
Camille.

30 Aug 2010 Oliver Woodford

Patrik: SC draws the image into the current axes as a standard MATLAB image object. However, it doesn't return the handle of the image. You can get the handle either by using IMSC (which behaves more like MATLAB's IMAGESC) or by using FINDOBJ. If you use the correct handle this should work.

30 Aug 2010 patrik

Great function. I have one problem though; i want the user of my gui to be able to click in the figure a have drawn with SC and recieve pixel coordinates. However when I try to add a buttondownfunction by writing
set(sc_handle,'ButtonDownFcn',@get_pixel_value) i get an error;
Error using set. Invalid handle.
Does an sc-object not have the property ButtonDownFcn or what am I doing wrong?

Thanks

19 Aug 2010 Oliver Woodford

C. Chaya & Justin: I've now included alternative to SC (called IMSC) which is the same as SC but with the display behaviour of IMAGESC, i.e. shows axes, variable aspect ratio etc.

18 Aug 2010 Oliver Woodford

Camille:
axis on

17 Aug 2010 Camille Couzi

How can I set XTick, YTick, XTickLabel and YTickLabel VISBLE as they are not handle of the text object (as is Title for Example)?
Writting :
set(get(gca, 'XTickLabel'), 'Visible', 'on');

sends an error:
??? Error using ==> set
Value must be a handle

Error in ==> ploteo_postfiltrado at 56
set(get(gca, 'XTickLabel'), 'Visible', 'on');
...

Thanks a lot for the help :-)

09 Jun 2010 Alize  
10 Dec 2009 K E

Helpful, thanks

12 Nov 2009 Ange  
12 Aug 2009 Oliver Woodford

Justin - if you prefer the image displaying properties of imagesc I suggest you use image(sc(X)). However, you then don't get the correct colorbar. If it's just the aspect ratio you don't like then call set(gca, 'DataAspectRatioMode', 'auto') after sc.

12 Aug 2009 Justin

The autopreservation of aspect ratio (mentioned by http://www.mathworks.com/matlabcentral/fileexchange/authors/27420) is the only thing I don't like about sc If I have a very long narrow matrix, imagesc scales it to display it in a standard sized matlab window. sc on the other hand gives me an extremely long narrow window. If there's an easy way to disable this please let me know.

Otherwise it's great.

30 Apr 2009 Jun wan

veri nice .bue i didn't try it

18 Mar 2009 Idillus

Nice

18 Mar 2009 Yair Altman

Extremely well done: excellent documentation, very instructive online demo (look at its code: so clean and compact!), lots of boundary-condition checks and clever packing of lots of options into a decievingly-simple interface. Some of this submission's defaults should have been imagesc's as well (for example, auto preservation of aspect ratio & axes elimination, not to mention the discretization issues). I love it!

17 Mar 2009 Oliver Woodford

The problem with not displaying titles and axis labels has now been fixed, thanks to C. Chaya's suggestion.

17 Mar 2009 Oliver Woodford

Removing the axes is a "feature" of the display side of this code. Unfortunately it does mean subplot titles and axes labels are hidden. This is something I've tried hard to avoid, but haven't found a way yet. You can use IMSHOW instead, but still get the benefits of SC, thus:
imshow(sc(X, 'jet'));

16 Mar 2009 C. Chaya

Otherwise, an excellent job. would give it 4.5 stars if the rating system would let me.

16 Mar 2009 C. Chaya

Doesn't show subplot titles. Must use

set(get(gca, 'Title'), 'Visible', 'on'); as a workaround.

28 Jan 2009 Andrew

Perfect. I used it to get around the fact that Matlab only allows one colormap per figure axis, and with some trial and error I even got the colorbar I wanted to show up. Great work Oliver.

15 Oct 2008 M HEMA NITHYA  
04 Sep 2008 Ernesto Moya

It's great.

25 Mar 2008 Ross McGurk

Finally found a relatively simple tool for overlaying some deformation maps on a binary image.
Took me about half an hour to get it to do what I was hoping it would (and this was helped due one of the examples in the demo).

Thanks very much for making this available!

10 Jan 2008 Felix Hebeler

Excellent package, saved my day! Great support too! Highly recommended...

15 Nov 2007 p p

best viewing code ever

14 Nov 2007 John Henkel

This is a pretty good package. I was just about to resort to either Zedgraph or Python to make some really pretty contour graphs (gotta pull out all the stops to get more funding. =P ), and ran across this. Very nice, and easy to use. The demo is a neat feature.

Updates
05 Sep 2007

Improved description & title.
Added new Matlab colormaps to function.

05 Sep 2007

Improvements and a bug fix to the function

14 Sep 2007

Faster image display, numerous other improvements

18 Sep 2007

Fixed resize issue

24 Oct 2007

Reduced cyclic number of code.

26 Oct 2007

Updates seem to be revision behind.

15 Nov 2007

Added multiple screen support. Fixed truncation bug when displaying multiple images.

14 Jan 2008

Bug fix to 'prob_jet' colormap.

03 Mar 2008

Introduced 'flow' map, based on 'phase' map

04 Mar 2008

Bug fix to 'stereo'

04 Apr 2008

Fixed saturation issue with 'prob_jet'

16 Apr 2008

Added 'stereo_col'. Changed text a bit.

08 May 2008

Fixed saturation issue with 'phase'.
Leave axes on but make invisible, so TITLE etc. still work.

14 May 2008

Improved magnification to deal with images too large for the screen.

10 Dec 2008

Added ability for users to define linear and non-linear colormaps. Added ability to combine images within SC. Removed ability to display multiple images, as it isn't key functionality.

16 Dec 2008

Fixed typo in the description!

17 Mar 2009

Allow axis labels and titles, using fix suggested by C. Chaya.

17 Aug 2010

Overhaul of the function, making it a wrapper for real2rgb and imdisp, with the more complex colormaps added in (including some new ones).

19 Aug 2010

Added IMSC wrapper function for SC, which replicates display behaviour of IMAGESC.

20 Aug 2010

Applied update to real2rgb

14 Dec 2012

Added disparity, disco and whed colormaps, and updated imsc to behave more like imagesc.

Contact us