Skip to content

Commit

Permalink
Update prcclip.m
Browse files Browse the repository at this point in the history
  • Loading branch information
wschwanghart committed Oct 6, 2020
1 parent 1d5086c commit 1bd86f2
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions @GRIDobj/prcclip.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@

qclip = sort(qclip);

[n,edges] = histcounts(A.Z(~isnan(A.Z(:))),'Normalization','cdf');
I = ~isnan(A.Z);

[n,edges] = histcounts(A.Z(I(:)),'Normalization','cdf');
lval = edges(find(n>=qclip(1),1,'first'));
uval = edges(find(n<(qclip(2)),1,'last'));
if lval == uval
warning('TopoToolbox:imageschs','percent clip returns flat matrix');

else
if nargout == 2
A.Z = max(A.Z,lval);
A.Z = min(A.Z,uval);
A.Z(I) = max(A.Z(I),lval);
A.Z(I) = min(A.Z(I),uval);
end

end

lims = [lval,uval];
Expand All @@ -79,13 +83,13 @@
lims = [-lims lims];
end

if nargout == 2
if flatmatrix
A(:,:) = lval;
else
A = max(A,lims(1));
A = min(A,lims(2));
end
end
% if nargout == 2
% if flatmatrix
% A(:,:) = lval;
% else
% A = max(A,lims(1));
% A = min(A,lims(2));
% end
% end


0 comments on commit 1bd86f2

Please sign in to comment.