forked from nepacheco/Continuum-Image-Analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalyzeImage.m
More file actions
72 lines (61 loc) · 2.62 KB
/
AnalyzeImage.m
File metadata and controls
72 lines (61 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function output = AnalyzeImage(Image,varargin)
%ANALYZEIMAGE analyzes the passed in image by asking the user to select
%notches and draw lines to determine the angle between notches
%
% 'TubeParameter' - Optional Argument determines how many notches should
% be expected on each tube or the outer diameter of a constant curvature
% tube. Default is 5 notches or 5 mm.
% 'Axis' - Optional Argument which is the axis to display the image one
% 'Style' - Name-Argument {'line','points'} which denotes if you want to
% analyze a notch using lines or points.
% 'ImgType' - Name-Argument {'notches', 'curvature'} to select if analyzing curve or notches
%****** INPUT PARSING *********************
% default values
tubeParameter = 5;
style = 'line';
styleOptions = {'line','points'};
imgType = 'curvature';
imgOptions = {'notches', 'curvature'};
p = inputParser();
addRequired(p,'Image');
addOptional(p,'TubeParameter',tubeParameter,@isnumeric);
addOptional(p,'axis',0);
addParameter(p,'Style',style, @(x) any(validatestring(x,styleOptions)));
addOptional(p,'ImgType', imgType, @(x) any(validatestring(x,imgOptions)));
parse(p,path,varargin{:});
tubeParameter = p.Results.TubeParameter;
ax = p.Results.axis;
if ax == 0
ax = gca;
end
style = p.Results.Style;
imgType = p.Results.ImgType;
%*********************************************
switch imgType
case 'notches'
% zoom on each notch gather data on angles
output = zeros(1,tubeParameter);
rectanglePositions = [];
for i = 1:tubeParameter
[notchImage, roi] = SelectRegion(Image,'previousRegions',rectanglePositions,...
'axis',ax,'title',"Select notch to analyze");
rectanglePositions = [rectanglePositions; roi];
theta = AnalyzeNotch(notchImage,'axis',ax,'Style',style);
output(i) = theta;
end
case 'curvature'
% set scale and calc bending radius
radius = 0;
% prompt to rotate image
Image = RotateImage(Image, 'axis',ax);
% 'select notch' to zoom in
[scaleImage, roi] = SelectRegion(Image, 'axis',ax, 'title', "Select area to zoom in to set scale");
% make line to set scale
scale = SetScale(scaleImage, 'axis', ax, 'Style', style, 'OD', tubeParameter)
% 'select notch' to zoom in
[arcImage, roi] = SelectRegion(Image, 'axis',ax, 'title', "Select area to zoom in on to find curvature");
% make polylines to create arc
r_vecPX = AnalyzeArc(arcImage, 'axis', ax, 'Style', style);
r_vec = r_vecPX * scale;
output = 1/(r_vec + tubeParameter/2);
end