Skip to content

Commit

Permalink
Added required dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sue Ann Koay authored and dpacheco0921 committed Aug 22, 2017
1 parent c765aca commit 7b42ac3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ignore thumbnails created by windows
Thumbs.db
*.asv
2 changes: 1 addition & 1 deletion MovieSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ function setContrast(obj, contrast)
saturation = MovieSlider.CONTRAST_RANGE(obj.contrastIndex);
sel = [1, 1 + find(diff(obj.pixelCDF) ~= 0)];

iValue = binarySearch(obj.pixelCDF(sel), [saturation, 1-saturation], 0, 0.5);
iValue = interp1(obj.pixelCDF(sel), 1:numel(sel), [saturation, 1-saturation], 'linear', 'extrap');
obj.pixelRange = obj.pixelValue([1 end]);
inRange = iValue > 1 & iValue < numel(sel);
iValue = iValue(inRange);
Expand Down
36 changes: 36 additions & 0 deletions rebin.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function rebinned = rebin(data, grouping, dimensions, aggregateFcn, varargin)

if nargin < 3 || isempty(dimensions)
[~,dimensions] = max(size(data));
end
if nargin < 4 || isempty(aggregateFcn)
aggregateFcn = @mean;
end

for dim = dimensions
original = size(data);
standardized = [ prod(original(1:dim-1)) ...
, original(dim) ...
, prod(original(dim+1:end)) ...
];
data = reshape(data, standardized);

numGroups = ceil(original(dim) / grouping);
if islogical(data)
rebinned = false(standardized(1), numGroups, standardized(end));
elseif isinteger(data)
rebinned = zeros(standardized(1), numGroups, standardized(end), 'like', data);
else
rebinned = nan(standardized(1), numGroups, standardized(end), 'like', data);
end
iSource = 1;
for iGroup = 1:numGroups
rebinned(:,iGroup,:) = aggregateFcn(data(:,iSource:min(iSource+grouping-1, end),:), 2, varargin{:});
iSource = iSource + grouping;
end
rebinned = reshape(rebinned, [original(1:dim-1), numGroups, original(dim+1:end)]);

data = rebinned;
end

end

0 comments on commit 7b42ac3

Please sign in to comment.