Skip to content

Commit

Permalink
Fix 8-bit conversion typo, interpolate gTable.
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronWebster committed Apr 16, 2021
1 parent 7c09c9a commit 87f0f5f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions utility/file/vcReadImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,18 @@
if nbits >= 14, maxDisplay = 2^16;
elseif nbits >= 12, maxDisplay = 2^14;
elseif nbits >= 10, maxDisplay = 2^12;
elseif nbits >= 8, maxDisplay = 20^10;
elseif nbits >= 8, maxDisplay = 2^10;
end
inImg = inImg/maxDisplay;

% Resize gTable to match image bits.
x_in = (0:1:size(gTable,1)-1) ./ 255;
y_in = gTable;
x_out = (0:1:2^(nbits+1)-1) ./ (2^(nbits+1)-1);
gTable = interp1(x_in, y_in, x_out, 'spline');

% Stretch image to match size of gamma table.
% This probably isn't necessary
inImg = inImg/imgMax;
inImg = round(inImg*(size(gTable,1)-1));
elseif max(inImg(:)) <= 1
% DAC values are [0, 2^nBits - 1]
Expand Down Expand Up @@ -363,4 +372,4 @@
error('Unknown image type.');
end

end
end

0 comments on commit 87f0f5f

Please sign in to comment.