Image Plot Using MATLAB

Some simple functions to plot an image using MATLAB.

  1. self-defined color mapping

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % self-defined colorbar
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    function clc_map = get_color_map(colors, clc_slices)
    n_clc = size(colors,1);
    clc_map = zeros(clc_slices * (n_clc - 1), 3);
    for j = 1:(n_clc - 1)
    for i = 1:3
    clc_map(1 + (j - 1) * clc_slices: j * clc_slices, i) = linspace(colors(j, i), colors(j+1, i), clc_slices);
    end
    end
    end

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % test code
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    clc_slices = 64;
    % some common colors : [1 1 1] white / [0 0 1] blue / [1 0 0] red
    start_color = [0 0 1];
    mid_color = [0.8500 0.3250 0.0980]
    end_color = [1 0 0];
    % row index : RGB ; column index : color
    colors = [start_color; mid_color; end_color];
    clc_map = get_color_map(colors, clc_slices);
  2. plot lines with color gradient and switch on cases

  3. 2D Interpolant using MATLAB

    下面是我第一次写文章作图时用MATLAB写的一些代码

  4. plot lines switch on cases


Image Plot Using MATLAB
http://example.com/2023/04/26/image_plot_matlab/
Author
Shijie Fang
Posted on
April 26, 2023
Licensed under