Skip to content

Commit

Permalink
大量新函数
Browse files Browse the repository at this point in the history
MATLAB.DataFun.
MeanSem
MinSubs

MATLAB.DataTypes.
CatMode
Cell2Mat
DimensionFun
FolderFun

MATLAB.Graph2D
MATLAB.Graph3D
MATLAB.Graphics
MATLAB.IOFun.DelimitedStrings2Table
  • Loading branch information
Ebola-Chan-bot committed Aug 23, 2021
1 parent 7aa2ba7 commit 0d473e4
Show file tree
Hide file tree
Showing 87 changed files with 2,358 additions and 3 deletions.
Binary file added +MATLAB/+DataFun/MeanSem.mlx
Binary file not shown.
Binary file added +MATLAB/+DataFun/MinSubs.mlx
Binary file not shown.
14 changes: 14 additions & 0 deletions +MATLAB/+DataTypes/CatMode.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
classdef CatMode
enumeration
%Function的返回值为标量
Scalar
%SplitDimensions为标量,且Function的返回值为类型、PackDimensions维度上尺寸均相同的数组
Linear
%Function的返回值为数值、逻辑、字符或字段相同的结构体数组,且尺寸完全相同
EsNlcs
%Function的返回值为数组,允许尺寸不同,但最终可以拼接成一整个大数组
CanCat
%不符合上述任何条件,或返回值为函数句柄
DontCat
end
end
Binary file added +MATLAB/+DataTypes/Cell2Mat.mlx
Binary file not shown.
Binary file added +MATLAB/+DataTypes/Cell2Mat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added +MATLAB/+DataTypes/DimensionFun.mlx
Binary file not shown.
Binary file added +MATLAB/+DataTypes/FolderFun.mlx
Binary file not shown.
Binary file added +MATLAB/+DataTypes/cell2mat.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions +MATLAB/+DataTypes/private/DFSuperCat.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function varargout = DFSuperCat(varargout,CM,SplitDimensions)
import MATLAB.DataTypes.CatMode
switch CM
case CatMode.Scalar
varargout=cellfun(@cell2mat,varargout,"UniformOutput",false);
case CatMode.Linear
if isempty(SplitDimensions)
%这里不能使用varargout=horzcat(varargout{:}),因为varargout元胞里有可能是空的
varargout=cellfun(@(Out)vertcat(Out{:}),varargout,"UniformOutput",false);
else
varargout=cellfun(@(Out)cat(SplitDimensions,Out{:}),varargout,"UniformOutput",false);
end
case CatMode.CanCat
varargout=cellfun(@MATLAB.DataTypes.Cell2Mat,varargout,"UniformOutput",false);
end
end
856 changes: 856 additions & 0 deletions +MATLAB/+Graph2D/LMSL示例图.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added +MATLAB/+Graph2D/LMSL示例数据.mat
Binary file not shown.
Binary file added +MATLAB/+Graph2D/LegendMultiShadowedLines.mlx
Binary file not shown.
Binary file added +MATLAB/+Graph2D/ShadowedLine.mlx
Binary file not shown.
239 changes: 239 additions & 0 deletions +MATLAB/+Graph2D/ShadowedLine.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added +MATLAB/+Graph3D/ColorAllocate.mlx
Binary file not shown.
26 changes: 26 additions & 0 deletions +MATLAB/+Graph3D/private/ColorDistribute.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function [Colors,Md] = ColorDistribute(NumberOfColorsToSuggest,ColorsToAvoid)
arguments
NumberOfColorsToSuggest(1,1)uint8
end
arguments(Repeating)
ColorsToAvoid(3,:)uint8
end
ColorsToAvoid=gpuArray([ColorsToAvoid{:}]);
SizeColor=width(ColorsToAvoid)+NumberOfColorsToSuggest;
DimensionSplit=ceil(double(SizeColor)^(1/3));
if ~isempty(ColorsToAvoid)
Cta=floor(double(ColorsToAvoid)/256*DimensionSplit);
AvoidIndices=(Cta(1,:)*DimensionSplit+Cta(2,:))*DimensionSplit+Cta(3,:);
else
AvoidIndices=[];
end
PossibleIndices=setdiff(0:DimensionSplit^3-1,AvoidIndices);
StartPoints=PossibleIndices(randsample(length(PossibleIndices),NumberOfColorsToSuggest));
StartBs=mod(StartPoints,DimensionSplit);
StartPoints=(StartPoints-StartBs)/DimensionSplit;
StartGs=mod(StartPoints,DimensionSplit);
StartPoints=(StartPoints-StartGs)/DimensionSplit;
[Colors,Md]=TryCircle([[StartPoints;StartGs;StartBs]*255/(DimensionSplit-1) ColorsToAvoid],[SizeColor SizeColor],NumberOfColorsToSuggest);
Colors=gather(uint8(Colors(:,1:NumberOfColorsToSuggest)));
Md=sqrt(double(Md));
end
12 changes: 12 additions & 0 deletions +MATLAB/+Graph3D/private/MinDistance.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function [M,I]=MinDistance(Colors,NumberOfVariables)
Colors=double(Colors);
NumberOfColors=width(Colors);
Color1Matrix=repmat(Colors,1,1,NumberOfColors);
Color2Matrix=repmat(permute(Colors,[1 3 2]),1,NumberOfColors,1);
Distance=squeeze(sum((Color1Matrix-Color2Matrix).^2,1));
Distance(logical(eye(NumberOfColors)))=Inf;
Distance(NumberOfVariables+1:end,NumberOfVariables+1:end)=Inf;
[M,I]=min(Distance,[],"all","linear");
M=gather(M);
I=gather(I);
end
27 changes: 27 additions & 0 deletions +MATLAB/+Graph3D/private/TryCircle.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function [Colors,Md]=TryCircle(Colors,SizeColors,NumberOfColorsToSuggest)
Colors=int16(Colors);
[Md,MinInd]=MinDistance(Colors,NumberOfColorsToSuggest);
FirstTime=true;
while true
[Index1,Index2]=ind2sub(SizeColors,MinInd);
if Index1<=NumberOfColorsToSuggest
[Colors,M,MinIndNew]=TryColor(Colors,Index1,Md,NumberOfColorsToSuggest,MinInd,FirstTime);
FirstTime=false;
if M>Md||M==Md&&MinIndNew~=MinInd
Md=M;
MinInd=MinIndNew;
continue;
end
end
if Index2<=NumberOfColorsToSuggest
[Colors,M,MinIndNew]=TryColor(Colors,Index2,Md,NumberOfColorsToSuggest,MinInd,FirstTime);
FirstTime=false;
if M>Md||M==Md&&MinIndNew~=MinInd
Md=M;
MinInd=MinIndNew;
continue;
end
end
break;
end
end
33 changes: 33 additions & 0 deletions +MATLAB/+Graph3D/private/TryColor.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function [Colors,Md,MinInd]=TryColor(Colors,Index,Md,NumberOfColorsToSuggest,MinInd,FirstTime)
persistent RGBs Untried
if isempty(RGBs)
RGBs=gpuArray(int32(cat(4,repmat((0:255)',1,256,256),repmat(0:255,256,1,256),repmat(shiftdim(0:255,-1),256,256))));
end
if FirstTime
Untried=true(256,256,256,"gpuArray");
end
Colors=int32(Colors);
PossibleDistances=sum((RGBs-permute(Colors(:,[1:Index-1 Index+1:end]),[3 4 5 1 2])).^2,4);
Candidates=find(all(PossibleDistances>Md,5)&Untried);
if isempty(Candidates)
Candidates=find(all(PossibleDistances==Md,5)&Untried);
end
if ~isempty(Candidates)
if numel(Candidates)>1
NewColor=gather(randsample(Candidates,1));
else
NewColor=gather(Candidates);
end
[NewR,NewG,NewB]=ind2sub([256 256 256],NewColor);
NewColor=squeeze(RGBs(NewR,NewG,NewB,:));
Colors(:,Index)=NewColor;
[M,MinInd]=MinDistance(Colors,NumberOfColorsToSuggest);
if M>Md
Untried=true(256,256,256);
Untried(NewColor(1)+1,NewColor(2)+1,NewColor(3)+1)=false;
Md=M;
else
Untried(NewColor(1)+1,NewColor(2)+1,NewColor(3)+1)=false;
end
end
end
Binary file added +MATLAB/+Graphics/FigureAspectRatio.mlx
Binary file not shown.
Binary file added +MATLAB/+IOFun/DelimitedStrings2Table.mlx
Binary file not shown.
5 changes: 5 additions & 0 deletions +MATLAB/+ImageSci/@OmeTiff/OmeTiff.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,10 @@ function setTag(obj,varargin)
Concatenate(OutputFile,Dimension,varargin)
Transcode(From,FromDimensionOrder,options)
Rename(From,To)
function Image5D=ReadAll(TiffPath)
TiffPath=MATLAB.ImageSci.OmeTiff(TiffPath);
Image5D=TiffPath.Read5D;
TiffPath.close;
end
end
end
2 changes: 1 addition & 1 deletion +MATLAB/Version.m
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
function V = Version
V.Me='2.4.0';
V.Me='2.5.0';
Loading

0 comments on commit 0d473e4

Please sign in to comment.