Skip to content

Commit

Permalink
Bug fix to overlay_scale
Browse files Browse the repository at this point in the history
Dimensions were flipped, resulting in undesired behavior for small and non-square images.
  • Loading branch information
tsipkens committed Feb 19, 2024
1 parent c668198 commit 529291f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions +tools/overlay_scale.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ function overlay_scale(pixsize, frac)

% Properties for scale bar.
margin = floor((size(I) .* 0.05));
bar_height = max(margin(2) / 7, 1);
bar_height = margin(2) / 5;
font_specs = {'HorizontalAlignment', 'right', ...
'VerticalAlignment', 'Bottom', ...
'FontSize', 11, 'FontWeight', 'bold'}; % properties of text label

hold on;
rectangle('Position', ...
[size(I,1) - margin(1) - bar_length, ...
size(I,2) - margin(2), ...
[size(I,2) - margin(2) - bar_length, ...
size(I,1) - margin(1), ...
bar_length, bar_height], ...
'FaceColor', [0 0 0], ...
'Curvature', 0.5);


if bar_length1 > 1e3 % then use micron
text(size(I,1) - margin(1), size(I,2) - margin(2) - bar_height/5, ...
text(size(I,2) - margin(2), size(I,1) - margin(1) - bar_height/5, ...
[num2str(bar_length1 ./ 1e3), ' um'], ...
font_specs{:});
else
text(size(I,1) - margin(1), size(I,2) - margin(2) - bar_height/5, ...
text(size(I,2) - margin(2), size(I,1) - margin(1) - bar_height/5, ...
[num2str(bar_length1), ' nm'], ...
font_specs{:});
end
Expand Down

0 comments on commit 529291f

Please sign in to comment.