-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewDataSingle.m
More file actions
76 lines (55 loc) · 2.06 KB
/
viewDataSingle.m
File metadata and controls
76 lines (55 loc) · 2.06 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
72
73
74
75
76
close all
clear all
addpath '../../utilities/matlab/'
% load source data
% SourcePts contains the coordinates of the vertices, SourceEdges contains a connectivity matrix for the definition of the edges
for i = 0:0
filename = [ 'ellipse_flow__t_' num2str( i ) ];
[SourcePts SourceEdges] = VTKPolyDataReader([ filename '.vtk']);
ellipseImg_p = zeros( [ 700, 1200 ] );
SourcePts_s = [];
% Change VTK to BW Image
for k = 1:size( SourcePts, 1 )
pt_x = SourcePts( k, 1 );
pt_y = SourcePts( k, 2 );
pt_x_o = pt_x + 80;
pt_y_o = pt_y + 30;
pt_x_s = pt_x_o * 5;
pt_y_s = pt_y_o * 5;
pt_x_i = round( pt_x_s ) + 200;
pt_y_i = round( pt_y_s ) + 200;
ellipseImg_p( pt_y_i, pt_x_i ) = 1;
SourcePts_s = [ SourcePts_s; pt_x, pt_y ];
end
figure;
imshow( ellipseImg_p );
% Interpolate between points
for k = 1:size( SourceEdges, 1 )
line_x = ( SourcePts( SourceEdges( k, : ), 1 ) + 80 ) .* 5 + 200;
line_y = ( SourcePts( SourceEdges( k, : ), 2 ) + 30 ) .* 5 + 200;
if ( sqrt( ( line_x( 2 ) - line_x( 1 ) )^2 + ( line_y( 2 ) - line_y( 1 ) )^2 ) > 1.0 )
if( line_x( 2 ) > line_x( 1 ) )
xq = line_x(1):0.01:line_x(2);
yq = interp1( line_x, line_y, xq );
else
xq = line_x(1):-0.01:line_x(2);
yq = interp1( line_x, line_y, xq );
end
for t = 1:size( xq(:), 1 )
ellipseImg_p( round( yq( t ) ), round( xq( t ) ) ) = 1;
end
end
end
figure;
imshow( ellipseImg_p );
title( 'Image Interp' );
ellipseF = imfill( ellipseImg_p );
figure;
imshow( ellipseF );
title( 'Filled' );
%
% save( [ filename '.mat' ], 'ellipseImg_p' );
% save( [ filename '_filled.mat' ], 'ellipseF' );
% save( [ filename '_Pts.mat' ], 'SourcePts_s' );
% save( [ filename '_Edges.mat' ], 'SourceEdges' );
end