-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetHeterogeneityMap.m
More file actions
32 lines (28 loc) · 1.11 KB
/
getHeterogeneityMap.m
File metadata and controls
32 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function heterogeneityMap = getHeterogeneityMap(stack, ROIsize)
%getHeterogeneityMap quantifies the local heterogeneity of an image by
%normalizing the image intensity with respect to the mean intensity of its
%local neighborhood.
%
% Input variables:
% - stack: Image stack (x,y,t).
% - ROIsize: Diameter (in pixels) of the circular neighborhood to be used.
%
% Output:
% - heterogenityMap has the same size as stack.
%
% By Rodrigo Migueles Ramirez (GitHub.com/Malvick17), 2024. McGill University, Canada.
% Please cite: Migueles-Ramirez, R., et.al., Journal of Microscopy, 2024.
% Create circular kernel
circleMask = circle(ROIsize, ROIsize,...
(ROIsize+1)/2, (ROIsize+1)/2, ROIsize/2);
h = circleMask./sum(circleMask, 'all', 'omitnan');
% Initialize hetMap
heterogeneityMap = zeros(size(stack));
% Get hetMap
for frame = 1:size(stack, 3)
image = double(stack(:,:,frame));
meanMap = imfilter(double(image), h);
differences = image - meanMap;
heterogeneityMap(:,:,frame) = differences./meanMap;
end
end