This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IMpath = 'C:\folder\input\'; % specify input/output folder | |
allImgs = {'filename1.tif',... | |
'filename2.tif'}; % specify filenames | |
% iterate through all images | |
for i=1:numel(allImgs) | |
fun = @(block_struct) imresize(block_struct.data,0.1); | |
imgOut = blockproc([IMpath,char(allImgs{i})],... | |
[1000 1000],fun,... | |
'UseParallel',true,... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% requires showTree.m | |
% --- create data | |
nObj = 100; | |
rng(3); | |
scale = 100; | |
data = rand(nObj,2)*scale; | |
% --- set up parameters | |
saveOutput = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function showTree( x,y,scale,varargin ) | |
xsize = 0.01*scale; | |
ysize = 0.03*scale; | |
radius = 0.03*scale; | |
treeColor = [0,150,10]/255; | |
% override tree color | |
if nargin>3 | |
treeColor = varargin{1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% JN Kather, 2015 | |
% Show the RGB gamut in RGB space and CIELAB space, then | |
% rotate the cubes and save the frames as image files to | |
% a subfolder ./output | |
% set parameters | |
turns = 1; % how often should the viewpoint turn, default 1 | |
balls = 70; % how many balls to plot | |
nSteps = 40; % how many viewpoints?, default 40 | |
saveOutput = false; % save output to files? default false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% (c) JN Kather 2015 | |
function hex = rgb2hex(rgb) | |
% expects a vector of three elements of RGB color values between 0 and 1. | |
% Returns a string containing the hex code of the color. | |
r = uint8(rgb(1)*255); | |
g = uint8(rgb(2)*255); | |
b = uint8(rgb(3)*255); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% JN Kather 2015 | |
% sorts a vector of hex colors by hue | |
% dependencies: needs functions rgb2hex and hex2rgb | |
dataDir = 'input/data/'; | |
% read color vector | |
colorList = readtable(strcat(dataDir,'/custom_color_list3.txt'),... | |
'ReadVariableNames',false); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% JN Kather 2015 | |
% calculate distance from a given point for a cloud of points, 3D | |
% cloud of points | |
Pts = rand(10000,3); | |
% calculate distance from P(px|py|pz) | |
px = 0.5; py = 0.5; pz = 0.5; | |
distance = sqrt( (Pts(:,1)-px).^2 + ... | |
(Pts(:,2)-py).^2 + ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% JN Kather 2015 | |
% calculate distance from a given point for a cloud of points, 2D | |
% cloud of points | |
Pts = rand(500,2); | |
% calculate distance from P(px|py) | |
px = 0.5; py = 0.5 | |
distance = sqrt((Pts(:,1)-px).^2 + (Pts(:,2)-py).^2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% JN Kather, 2015 | |
% Show a CIELAB color cube composed of 25^3 balls | |
% note: Matlab CIELAB colorspace goes approx. from -108 to +100 as measured | |
% with: colors = rgb2lab(jet(100)); min(colors(:)), max(colors(:)) | |
figure(); | |
[X,Y,Z] = meshgrid(linspace(-108,100,15)); | |
colors = lab2rgb([double(X(:)),double(Y(:)),double(Z(:))]); | |
scatter3(X(:),Y(:),Z(:),100,colors,'filled'); | |
xlabel('L'); ylabel('a'); zlabel('b'); | |
axis equal tight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% JN Kather, 2015 | |
% Show the RGB gamut in CIELAB space | |
figure(); | |
[X,Y,Z] = meshgrid(linspace(0,1,25)); | |
colors = ([X(:),Y(:),Z(:)]); | |
colorsLAB = rgb2lab(colors); | |
scatter3(colorsLAB(:,1),colorsLAB(:,2),colorsLAB(:,3),100,colors,'filled'); |
NewerOlder