psy008
Newbie level 1
help with matlab codes
i got a project on 3 d scanning in matlab .. i ve the following code but its giving some errors .. anyone can help me with this?? also this code s for video i want to use it for symmetrical image.. is it possible??
% Read in video data from camera
video = aviread('C:\N_3d\bottleExperiment\bottle.avi');
% Predefined Variables
frames = 300;
xMin = 10;
xMax = 220;
yMin = 90;
yMax = 225;
iRadFilter = 1.57;
% Split Video into Separate Frames And Apply Threshold
for j = 1:frames
I,:,:,j) = video(j).cdata;
BW,:,j) = threshold(I,:,:,j),70,xMin,xMax,yMin,yMax,1);
end
% Radon Transform
for y = xMin:xMax
for x = yMin:yMax
for i = 1:frames
R(x-yMin+1,i,y-xMin+1) = BW(y,x,i);
end
end
end
% Inverse Radon Transform
for i = 1:xMax-xMin
II,:,i) = iradon(R,:,i),360/frames,'linear','none');
end
% Average Filter
D = find(II>iRadFilter);
II(D) =2;
% Thresholding and Edge Detection for Slice Projections
for i = 1:xMax-xMin
BB,:,i) = threshold(II,:,i),2,0,0,0,0,2);
EE,:,i) = edge(BB,:,i),'canny');
end
% Boundary Detection
for i = 1:length(EE)
c = 1;
for x = 1:96
for y = 1:96
if EE(x,y,i) ==1
H = bwtraceboundary(EE,:,i), [x,y], 'W', 8,1000,'counterclockwise');
if length(H)>10
contour(c,i).x = H,2);
contour(c,i).y = H,1);
contour(c,i).z = linspace(abs(i-210),abs(i-210),length(H))';
contour(c,i).length = length(H);
EE(contour(c,i).y),contour(c,i).x),i) = 0;
c= c+1;
end
end
end
end
end
% Plot the Point Cloud
for i = 1:length(contour)
plot3(contour(i).x),contour(i).y),contour(i).z),'.');
hold on;
end
i got a project on 3 d scanning in matlab .. i ve the following code but its giving some errors .. anyone can help me with this?? also this code s for video i want to use it for symmetrical image.. is it possible??
% Read in video data from camera
video = aviread('C:\N_3d\bottleExperiment\bottle.avi');
% Predefined Variables
frames = 300;
xMin = 10;
xMax = 220;
yMin = 90;
yMax = 225;
iRadFilter = 1.57;
% Split Video into Separate Frames And Apply Threshold
for j = 1:frames
I,:,:,j) = video(j).cdata;
BW,:,j) = threshold(I,:,:,j),70,xMin,xMax,yMin,yMax,1);
end
% Radon Transform
for y = xMin:xMax
for x = yMin:yMax
for i = 1:frames
R(x-yMin+1,i,y-xMin+1) = BW(y,x,i);
end
end
end
% Inverse Radon Transform
for i = 1:xMax-xMin
II,:,i) = iradon(R,:,i),360/frames,'linear','none');
end
% Average Filter
D = find(II>iRadFilter);
II(D) =2;
% Thresholding and Edge Detection for Slice Projections
for i = 1:xMax-xMin
BB,:,i) = threshold(II,:,i),2,0,0,0,0,2);
EE,:,i) = edge(BB,:,i),'canny');
end
% Boundary Detection
for i = 1:length(EE)
c = 1;
for x = 1:96
for y = 1:96
if EE(x,y,i) ==1
H = bwtraceboundary(EE,:,i), [x,y], 'W', 8,1000,'counterclockwise');
if length(H)>10
contour(c,i).x = H,2);
contour(c,i).y = H,1);
contour(c,i).z = linspace(abs(i-210),abs(i-210),length(H))';
contour(c,i).length = length(H);
EE(contour(c,i).y),contour(c,i).x),i) = 0;
c= c+1;
end
end
end
end
end
% Plot the Point Cloud
for i = 1:length(contour)
plot3(contour(i).x),contour(i).y),contour(i).z),'.');
hold on;
end