Monday, 15 July 2013

plot - Matlab imagesc plotting nan values -



plot - Matlab imagesc plotting nan values -

when using imagesc visualize info contains nan values, matlab treats them minimum value(in grayness paints them black, jet - blue, etc). jet colormap doesn't contain neither black nor white. possible display nan values black/white? example:

data = [0 0 0 ; .5 .5 .5 ;1 1 1;nan nan nan];

should yield blue-green-red-black strips.

thanks

i wrote custom function display nan values see-through, i.e. alpha value of 0.

function h = imagesc2 ( img_data ) % wrapper imagesc, formatting going on nans % plotting data. removing , scaling axes (this image plotting) h = imagesc(img_data); axis image off % setting alpha values if ndims( img_data ) == 2 set(h, 'alphadata', ~isnan(img_data)) elseif ndims( img_data ) == 3 set(h, 'alphadata', ~isnan(img_data(:, :, 1))) end if nargout < 1 clear h end

the nans displayed same colour figure background colour. if remove line axis image off, nans shown same colour axis background colour. function assumes input images of size n x m (single channel) or n x m x 3 (three channels), may need modification depending on use.

with data:

data = [0 0 0 ; .5 .5 .5 ;1 1 1;nan nan nan]; imagesc2(data); axis on set(gca, 'color', [0, 0, 0])

matlab plot

No comments:

Post a Comment