Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • Select matrix and copy

  • In MATLAB, paste into variable ("a" in the example below):

First type

>> a= [

then paste (Ctrl^V)

then close bracket, and Enter ]

  • Create the image
>> figure
>> imshow (a)

(or on the same line)

>> figure, imshow(a)
  • Zoom in to see

Color

If the image is intensities, imshow displays a grayscale image. To display in another color,

1) convert to index

2) imshow with colormap

Converting to index just means convert to numbers into the colormap.

>> num_colorsinmap = 256;
>> a_indexed = round( a * 255 );
  • Works for values between 0 and 1; scales 0 to bottom of coloramp, and 1 to top
>> cmap = hot( num_colorsinmap );
  • For other colormap options, hype >> help colormap 
  • Examples include hot, hsv, jet, and with CSPM you get jettop, jetbot
>> figure, imshow(a_indexed, cmap)

You could also do this in one line:

>> figure, imshow( round(a*255), hot(256) )

Increase resolution (smooth)

Use the interp2 function to resample at a factor of the original resolution.

>> res_factor = 4;
>> a_res = interp2( a, res_factor );
>> a_res_indexed = round( a_res * 255 );
>> figure, imshow(a_res_indexed, cmap)

Example script

Use the following MATLAB script to create figures. Load the data into "a" first.


View file
nameeeg_map.m
height250