How to show a colorbar of a certain range?

Sean de Wolski asked on 15 Jul 2011
Latest activity: Answer by Titus Edelhofer on 15 Jul 2011

Hello all and happy Friday!

Let's say I have an image with a colormap and corresponding colorbar

I = imread('cameraman.tif');
imshow(I);
colormap jet
colorbar

I want the colorbar to only show colors for a certain range of values:

range_care = [100 150]; %show colors for values 100:150

Any ideas?

Thanks, plzzzz rply qckly its urgenttt

had to :)

0 comments

Tags

Products

    2 answers

    Titus Edelhofer answered on 15 Jul 2011
    Accepted answer

    Hi,

    something like this:

    h = colorbar;
    set(h, 'ylim', [100 150])
    

    Titus

    2 comments

    Titus Edelhofer on 15 Jul 2011

    sorry, if it wasn't quick enough ;-)

    Sean de Wolski on 15 Jul 2011

    That's it, and plenty quick - before third cup of coffee even...

    Harsha Vardhan Rao Avunoori answered on 15 Jul 2011

    Okay I don't know whether this is the right one or not.

    But I have tried this.

    I = imread('cameraman.tif');
    imshow(I,'DisplayRange',[100 150]);
    colormap jet
    colorbar
    

    Hope this is what your looking for.

    -Harsha

    1 comment

    Sean de Wolski on 15 Jul 2011

    Thank you, but that's not what I'm looking for. That turns everything above 150 to red and everything below 100 to blue. I want the full range of the colormap displayed on the image; just the colorbar showing a fraction of the range.

    Contact us at files@mathworks.com