diff --git a/plotting/Colormaps/RainbowColormap/RainbowColormap/SetXLimYLimXTick.m b/plotting/Colormaps/RainbowColormap/RainbowColormap/SetXLimYLimXTick.m new file mode 100644 index 0000000..fb540ce --- /dev/null +++ b/plotting/Colormaps/RainbowColormap/RainbowColormap/SetXLimYLimXTick.m @@ -0,0 +1,24 @@ +% % function to set ticks of X-axis and Y-axis + +function SetXLimYLimXTick(handle,xmin,xmax,ymin,ymax) + +set(handle,'XLim',[xmin xmax]); +set(handle,'YLim',[ymin ymax]); + +xtvec=[xmin ,get(gca,'XTick'), xmax]; +ytvec=[ymin ,get(gca,'YTick'), ymax]; + +xtvec=unique(xtvec); +ytvec=unique(ytvec); + +set(handle,'XTick',xtvec); +set(handle,'YTick',ytvec); + +% % --------------------------------------- +% % This program or any other program(s) supplied with it does not provide any warranty direct or implied. +% % This program is free to use/share for non-commercial purpose only. +% % Kindly reference the work. +% % Author: Dr. Murtaza Khan +% % LinkedIn: http://www.linkedin.com/pub/dr-murtaza-khan/19/680/3b3 +% % ResearchGate: http://www.researchgate.net/profile/Murtaza_Khan2/ +% % --------------------------------------- diff --git a/plotting/Colormaps/RainbowColormap/RainbowColormap/main.m b/plotting/Colormaps/RainbowColormap/RainbowColormap/main.m new file mode 100644 index 0000000..44430c4 --- /dev/null +++ b/plotting/Colormaps/RainbowColormap/RainbowColormap/main.m @@ -0,0 +1,37 @@ +clc, close all, clear all + +dx = 0.8; % amount of blue and red at the beginning & end of the colormap +n = 32; % number of entries in the rainbow colormap +[cmapRainbow, g, f]=rainbow_cmap(n, dx); +% % ----------------------------------------------- +% % Display an image in bone and rainbow colormaps +load spine +figure, image(X), colormap(bone), title('\bf Image in Bone colormap'); +figure, image(X), colormap(cmapRainbow), title('\bf Image in Rainbow colormap'); + +% % ----------------------------------------------- +% % Plot transfer functions of rainbow colormap +figure, hold on +plot(g,cmapRainbow(:,1),'r','linewidth',2); %red +plot(g,cmapRainbow(:,2),'g','linewidth',2); %green +plot(g,cmapRainbow(:,3),'b','linewidth',2); %blue +% legend('R','G','B'); +handle1=gca; +SetXLimYLimXTick(handle1,0,6,-0.1,1.1); +grid on +title('\bf Rainbow colormap transfer functions'); +xlabel('\bf Scalar value g'); +ylabel('\bf Transfer functions: R, G, B'); + + +% % ----------------------------------------------- +% % This program or any other program(s) supplied with it does not provide any warranty direct or implied. +% % This program is free to use/share for non-commercial purpose only. +% % Kindly reference the work. +% % Author: Dr. Murtaza Khan +% % LinkedIn: http://www.linkedin.com/pub/dr-murtaza-khan/19/680/3b3 +% % ResearchGate: http://www.researchgate.net/profile/Murtaza_Khan2/ +% % ----------------------------------------------- + + + diff --git a/plotting/Colormaps/RainbowColormap/RainbowColormap/rainbow_cmap.m b/plotting/Colormaps/RainbowColormap/RainbowColormap/rainbow_cmap.m new file mode 100644 index 0000000..075b33f --- /dev/null +++ b/plotting/Colormaps/RainbowColormap/RainbowColormap/rainbow_cmap.m @@ -0,0 +1,41 @@ +% % INPUT +% % n: number of entries in the rainbow colormap +% % dx: it controls the amount of pure blue and red used at the +% % beginning and the end of the colormap, respectively + +% % OUTPUT +% % cmapRainbow: Rainbow color map values of Red, Green, Blue +% % g: scalar values between dx & (6-dx) +% % f: n values between 0 and 1. g is evaluated at these values + +function [cmapRainbow, g, f]=rainbow_cmap(n, dx) + +f = linspace(0,1,n); % generates n points between 0 and 1. + +cmapRainbow=[]; +for i=1:n + g(i) = (6 - 2*dx) * f(i) + dx ; %scale f between dx and (6-dx) + R = max(0, (3 - abs(g(i) - 4) - abs(g(i) - 5))/2); + G = max(0, (4 - abs(g(i) - 2) - abs(g(i) - 4))/2); + B = max(0, (3 - abs(g(i) - 1) - abs(g(i) - 2))/2); + cmapRainbow(i,:)=[R, G, B]; +end + +g=g'; %change g to column vector +f=f'; %change f to column vector + + +% % ----------------------------------------------- +% % This program or any other program(s) supplied with it does not provide any warranty direct or implied. +% % This program is free to use/share for non-commercial purpose only. +% % Kindly reference the work. +% % Author: Dr. Murtaza Khan +% % LinkedIn: http://www.linkedin.com/pub/dr-murtaza-khan/19/680/3b3 +% % ResearchGate: http://www.researchgate.net/profile/Murtaza_Khan2/ +% % ----------------------------------------------- + + + + + + diff --git a/plotting/Colormaps/RainbowColormap/RainbowColormap/rainbowcolormapfigures.png b/plotting/Colormaps/RainbowColormap/RainbowColormap/rainbowcolormapfigures.png new file mode 100644 index 0000000..631e751 Binary files /dev/null and b/plotting/Colormaps/RainbowColormap/RainbowColormap/rainbowcolormapfigures.png differ diff --git a/plotting/Colormaps/RainbowColormap/RainbowColormap/readme.txt b/plotting/Colormaps/RainbowColormap/RainbowColormap/readme.txt new file mode 100644 index 0000000..2d78798 --- /dev/null +++ b/plotting/Colormaps/RainbowColormap/RainbowColormap/readme.txt @@ -0,0 +1,25 @@ +Rainbow Colormap +--------------------------------------- +Unzip the archive, add to current working directory and run the main.m program. Following MATLAB files are included in the archive: + +main.m +A simple test program to plot: +(1) Transfer function of Rainbow Colormap +(2) Display two images, one in bone colormap and one in rainbow colormap + +rainbow_cmap.m +A function to compute Rainbow colormap values. + + +SetXLimYLimXTick.m +A function to set ticks of X-axis and Y-axis + +--------------------------------------- +% % This program or any other program(s) supplied with it does not provide any warranty direct or implied. +% % This program is free to use/share for non-commercial purpose only. +% % Kindly reference the work. +% % Author: Dr. Murtaza Khan +% % LinkedIn: http://www.linkedin.com/pub/dr-murtaza-khan/19/680/3b3 +% % ResearchGate: http://www.researchgate.net/profile/Murtaza_Khan2/ +--------------------------------------- + diff --git a/plotting/Colormaps/RainbowColormap/RainbowColormap/reference.txt b/plotting/Colormaps/RainbowColormap/RainbowColormap/reference.txt new file mode 100644 index 0000000..2bef321 --- /dev/null +++ b/plotting/Colormaps/RainbowColormap/RainbowColormap/reference.txt @@ -0,0 +1,7 @@ +Murtaza Khan, "Rainbow Colormap", June. 2015. +---------------------------------------------- + +LaTeX + +\bibitem{KhanJune2015} +Murtaza Khan, \emph{Rainbow Colormap}, June 2015. \ No newline at end of file diff --git a/plotting/Colormaps/RainbowColormap/license.txt b/plotting/Colormaps/RainbowColormap/license.txt new file mode 100644 index 0000000..89495c3 --- /dev/null +++ b/plotting/Colormaps/RainbowColormap/license.txt @@ -0,0 +1,24 @@ +Copyright (c) 2015, Murtaza Khan +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE.