Differences
This shows you the differences between two versions of the page.
— | matlab [2020/06/10 21:38] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== MATLAB-Stuff ====== | ||
+ | * [[code: | ||
+ | ===== Code and other snippets ===== | ||
+ | ==== Write a multipage TIFF ==== | ||
+ | <code MATLAB> | ||
+ | for i=1:100 | ||
+ | a(:,:, | ||
+ | imwrite(a(:,:, | ||
+ | end | ||
+ | size(a) | ||
+ | </ | ||
+ | Adapted from [[http:// | ||
+ | |||
+ | ==== start matlab headless with some file ==== | ||
+ | cd filepath | ||
+ | matlab -r file (WITHOUT .m extension!) | ||
+ | ==== turn off warning about big images ==== | ||
+ | <code MATLAB> | ||
+ | ==== Overlay Image over another one ==== | ||
+ | <code MATLAB> | ||
+ | Img = imnoise(phantom(64)); | ||
+ | Threshold = graythresh(Img); | ||
+ | BW = im2bw(Img, | ||
+ | |||
+ | Color = [155 188 221] % define overlay colour RGB (this is the unibe-presentation color) | ||
+ | |||
+ | Img = im2uint8(mat2gray(Img)); | ||
+ | red = Img; | ||
+ | green = Img; | ||
+ | blue = Img; | ||
+ | |||
+ | red(BW) = Color(1); | ||
+ | green(BW) = Color(2); | ||
+ | blue(BW) = Color(3); | ||
+ | |||
+ | Overlay = cat(3, red, green, blue); % make RGB-image | ||
+ | |||
+ | figure % display everything | ||
+ | subplot(131) | ||
+ | imshow(Img, | ||
+ | title(' | ||
+ | subplot(132) | ||
+ | imshow(BW, | ||
+ | title([' | ||
+ | subplot(133) | ||
+ | imshow(Overlay, | ||
+ | title(' | ||
+ | </ | ||
+ | adapted from [[http:// | ||
+ | |||
+ | ==== Threshold Image ==== | ||
+ | And return Human-readable Threshold | ||
+ | <code MATLAB> | ||
+ | Img = imread(' | ||
+ | Threshold = graythresh(Img); | ||
+ | BW = im2bw(Img, | ||
+ | Bitdepth = intmax(class(Img)); | ||
+ | disp([' | ||
+ | figure | ||
+ | subplot(121) | ||
+ | imshow(Img) | ||
+ | title(' | ||
+ | subplot(122) | ||
+ | imshow(BW) | ||
+ | title([' | ||
+ | </ | ||
+ | |||
+ | ==== Select Components in a (thresholded) Image ==== | ||
+ | <code MATLAB> | ||
+ | BW = imread(' | ||
+ | BW = im2bw(BW, | ||
+ | |||
+ | % inform user | ||
+ | wait=helpdlg(' | ||
+ | uiwait(wait) | ||
+ | |||
+ | % open figure (bwselect outputs figure to screen, so we put it in a subplot | ||
+ | % to start with. when right mouse button is pressed, right figure is updated | ||
+ | figure; | ||
+ | subplot(121) | ||
+ | BW2 = bwselect(BW); | ||
+ | subplot(122) | ||
+ | imshow(BW2) | ||
+ | </ |