Skip to content

Commit

Permalink
update for more consistent transparency contrast behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
bogpetre committed Sep 13, 2023
1 parent 7136038 commit 51fbd67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CanlabCore/@image_vector/render_on_surface.m
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@
set(surface_handles(i), 'EdgeColor', 'none');

if doscaledtrans
z = c/max(abs(c));
z = c/max(abs(datvec));
z = enhance_contrast(z);
set(surface_handles(i), 'FaceVertexAlphaData',abs(z));
set(surface_handles(i), 'FaceAlpha', 'interp');
Expand Down
10 changes: 6 additions & 4 deletions CanlabCore/fmridisplay_helper_functions/render_blobs.m
Original file line number Diff line number Diff line change
Expand Up @@ -621,13 +621,14 @@

if dotrans
% Set transparency

if dotrans
s = max(abs(Z(Z~=0 & ~isnan(Z))));
Z(~isnan(Z)) = enhance_contrast(Z(~isnan(Z))/s)*s;
end

if ~docolormap || dosplitcolor, Zscaled = abs(Z); end

Zscaled(isnan(Zscaled)) = 0;
Zscaled = enhance_contrast(Zscaled);
Zscaled = abs(Zscaled);

if ~isempty(transvalue)
% constant transparency value
set(h, 'AlphaDataMapping', 'scaled', 'AlphaData', transvalue .* double(abs(Z) > 0), 'FaceAlpha', 'interp')
Expand All @@ -637,6 +638,7 @@
% Note: changed by Tor, 2015. Zscaled values > 1
% were messing up transparency scale for underlay.
% Max should be 1.

set(h, 'AlphaDataMapping', 'scaled', 'AlphaData', Zscaled ./ max(abs(Zscaled(:))), 'FaceAlpha', 'interp');
end

Expand Down

0 comments on commit 51fbd67

Please sign in to comment.