Dear all,
Thanks in advance for your help.
I'm trying to plot several IMPROFILE lines and export their values to excel with the code below.
I'm getting the user to select an image and draw a line along which a predetermined number of perpendicular IMPROFILE lines will be plotted.
However, the code only writes to excel the values from the first line (when i=0), whereas all the other IMPROFILE lines originate NaN values for profile_3d and all the other arrays.
Has anyone have any ideas why that's the case?
Thanks!
Giuseppe
[FileName,PathName] = uigetfile('*.jpg','Select the IMAGE');
imshow(FileName);figure(gcf);
I=imread(FileName);
g = imline;
pos = wait(g);
cat=diff(pos); catx=abs(cat(1)); caty=abs(cat(2));
len = sqrt(catx.^2+caty.^2);
hp = 75; %half length of profile line
int_num = 5; % Number of profile lines
int = len/int_num;
offset = 1;
x0 = pos(1) + caty*hp/len; %top point
y0 = pos(3) - catx*hp/len; %top point
x1 = pos(1) - caty*hp/len; %bottom point
y1 = pos(3) + catx*hp/len; %bottom point
for i=0:1:int_num
x0 = x0 + i*int*(catx*hp/len);
y0 = y0 + i*int*(caty*hp/len);
x1 = x1 + i*int*(catx*hp/len);
y1 = y1 + i*int*(caty*hp/len);
xi= [x1 x0];
yi= [y1 y0];
line(xi,yi);
profile_3d = improfile(I,xi,yi);
Vprofile_1d = profile_3d(:,:,1);
Hprofile_1d = rot90(Vprofile_1d);
xlswrite('NAME.xlsx',Hprofile_1d,1, sprintf('A%d',offset));
offset = offset + 1;
end
Thanks in advance for your help.
I'm trying to plot several IMPROFILE lines and export their values to excel with the code below.
I'm getting the user to select an image and draw a line along which a predetermined number of perpendicular IMPROFILE lines will be plotted.
However, the code only writes to excel the values from the first line (when i=0), whereas all the other IMPROFILE lines originate NaN values for profile_3d and all the other arrays.
Has anyone have any ideas why that's the case?
Thanks!
Giuseppe
[FileName,PathName] = uigetfile('*.jpg','Select the IMAGE');
imshow(FileName);figure(gcf);
I=imread(FileName);
g = imline;
pos = wait(g);
cat=diff(pos); catx=abs(cat(1)); caty=abs(cat(2));
len = sqrt(catx.^2+caty.^2);
hp = 75; %half length of profile line
int_num = 5; % Number of profile lines
int = len/int_num;
offset = 1;
x0 = pos(1) + caty*hp/len; %top point
y0 = pos(3) - catx*hp/len; %top point
x1 = pos(1) - caty*hp/len; %bottom point
y1 = pos(3) + catx*hp/len; %bottom point
for i=0:1:int_num
x0 = x0 + i*int*(catx*hp/len);
y0 = y0 + i*int*(caty*hp/len);
x1 = x1 + i*int*(catx*hp/len);
y1 = y1 + i*int*(caty*hp/len);
xi= [x1 x0];
yi= [y1 y0];
line(xi,yi);
profile_3d = improfile(I,xi,yi);
Vprofile_1d = profile_3d(:,:,1);
Hprofile_1d = rot90(Vprofile_1d);
xlswrite('NAME.xlsx',Hprofile_1d,1, sprintf('A%d',offset));
offset = offset + 1;
end