Skip to content

Instantly share code, notes, and snippets.

@danielronnkvist
Last active August 29, 2015 14:09
Show Gist options
  • Save danielronnkvist/d3f1fe2bfdf3035e0d31 to your computer and use it in GitHub Desktop.
Save danielronnkvist/d3f1fe2bfdf3035e0d31 to your computer and use it in GitHub Desktop.
lab1
% Bob lab 1
clear all
%% Load and plot gfun
load('gfun.mat');
plot(gfun)
figure
plot(2.^gfun)
%% Read images
i1 = imread('Img1.tiff');
i2 = imread('Img2.tiff');
i3 = imread('Img3.tiff');
i4 = imread('Img4.tiff');
i5 = imread('Img5.tiff');
i6 = imread('Img6.tiff');
i7 = imread('Img7.tiff');
i8 = imread('Img8.tiff');
i9 = imread('Img9.tiff');
i10 = imread('Img10.tiff');
i11 = imread('Img11.tiff');
i12 = imread('Img12.tiff');
i13 = imread('Img13.tiff');
i14 = imread('Img14.tiff');
%% Find highest intesity in i3
bwim = rgb2gray(i3);
maxval = max(max(bwim(:)));
[x,y] = find(bwim == maxval);
maxPos = [x, y]
%% find minimum value of i14
bwim = rgb2gray(i14);
minval = min(min(bwim(:)));
[x, y] = find(bwim == minval);
minPos = [x(1), y(1)]
%% Find a median
bwim = rgb2gray(i9);
medval = median(median(single(bwim)));
[x, y] = find(bwim == medval);
medPos = [x(1), y(1)]
%% Generate arrays for each position in each image
minimums = [];
maximums = [];
mediumums = [];
for i=1:14
im = strcat('Img', int2str(i));
im = strcat(im, '.tiff');
im = imread(im);
min = im(minPos(1),minPos(2));
minimums = [minimums, min];
max = im(maxPos(1), maxPos(2));
maximums = [maximums, max];
med = im(medPos(1), medPos(2));
mediumums = [mediumums, med];
end
minimums
maximums
mediumums
%% plot them shits
figure
plot(minimums)
hold on
plot(maximums, 'r')
plot(mediumums, 'g')
legend('min', 'max', 'med')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment