Skip to content

Instantly share code, notes, and snippets.

@MarcinKonowalczyk
Last active July 27, 2020 16:51
Show Gist options
  • Save MarcinKonowalczyk/8408e416c8ebc33287d05d938022336c to your computer and use it in GitHub Desktop.
Save MarcinKonowalczyk/8408e416c8ebc33287d05d938022336c to your computer and use it in GitHub Desktop.
[Matab] Image operations
%% Bake-in colormap
Im = frame_stack(:,:,1); % Pick image
Im = Im-min(Im(:)); Im = Im./max(Im(:)); % Normalise
%Im = Im-prctile(Im(:),1); Im = Im./prctile(Im(:),99); % Normalise to percentiles
Im = round(Im*255); % 0-255
cm = viridis(256); % Colormap (ideally uniform)
Im = ind2rgb(Im,cm); % Bake
figure(1); image(Im) % Looks good
%% Save as multipage-tiff
filename = 'blah.tiff';
D = frame_stack;
imwrite(D(:,:,1),filename); % Save first frame
for j = 2:size(D,3)
    imwrite(D(:,:,j),filename,'WriteMode','append'); % Append all the other frames
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment