How to store feature extracted data into 2d array

I am try to store the output of the feature extracted data of image into 2d array. But the output is 55 numeric values. The output is printed line by line. How can I store this 55 numbers into 2d array. I put this output into one variable, from the variable to store the data into array format for storing into excel sheet. If the output is stored as same in excel, It cannot store in row format, It store in column format like presented output format.So how to store this data into 2d array. My code and my output is
x = imread(sprintf('E:/apps/project/TELUGU data/telugu sep/1/ (1).jpg'))
n = feature_extractor_2d(x);
output is
-0.4000
0.4000
0.6000
-0.2000
0.2600
0.3355
0.1685
0.2055
0.0317
0.2000
1.0000
0.8000
0.6000
0.6494
0
0.1481
0.1852
0.0206
0.8000
0.6000
0.4000
0.4000
0.1132
0.5556
0.1564
0.1564
0.0247
0.6000
0.6000
0.6000
0
0.5788
0.0731
0.1865
0.1404
0.0264
0.8000
0
0.6000
0.4000
0.0023
0.3949
0.3210
0.2564
0.0220
0.6000
0.6000
0.8000
0.6000
0.6488
0.1943
0.0374
0.1070
0.0285
1.0000
Can any one help me how to divide and store this type of data into array. Thank you

4 Comments

can you copy feature_extractor_2d.m code here...so that I can edit to save your variable into column.
Thank you sir, Code is
function [features]=feature_extractor_2d(image);
if length(size(image))>2
image=rgb2gray(image);
image=im2bw(image,graythresh(image));
end
image=bwmorph(image,'skel',inf);
image=discourser(image);
original_image=image;
row=size(image,1);
column=size(image,2);
add_rows=0;
add_columns=0;
if row<9
add_rows=9-row;
end
if column<9
add_columns=9-column;
end
if mod(add_rows,2)==0
image=[zeros(add_rows/2,column);image;zeros(add_rows/2,column)];
else
image=[zeros((add_rows-1)/2,column);image;zeros((add_rows+1)/2,column)];
end
row=size(image,1);
if mod(add_columns,2)==0
image=[zeros(row,(add_columns)/2),image,zeros(row,(add_columns)/2)];
else
image=[zeros(row,(add_columns-1)/2),image,zeros(row,(add_columns+1)/2)];
end
column=size(image,2);
n_rows=ceil(row/3)*3-row; % no of rows of zeros to be added
n_columns=ceil(column/3)*3-column;
if mod(n_rows,2)==0
image=[zeros(n_rows/2,column);image;zeros(n_rows/2,column)];
else
image=[zeros((n_rows-1)/2,column);image;zeros((n_rows+1)/2,column)];
end
row=size(image,1);
if mod(n_columns,2)==0
image=[zeros(row,(n_columns)/2),image,zeros(row,(n_columns)/2)];
else
image=[zeros(row,(n_columns-1)/2),image,zeros(row,(n_columns+1)/2)];
end
column=size(image,2);
column_zone_height=row;
column_zone_width=column/3;
column_zone1=image(1:column_zone_height,1:column_zone_width);
column_zone2=image(1:column_zone_height,(column_zone_width+1):2*column_zone_width);
column_zone3=image(1:column_zone_height,(2*column_zone_width+1):end);
row_zone_height=row/3;
row_zone_width=column;
row_zone1=image(1:row_zone_height,1:row_zone_width);
row_zone2=image((row_zone_height+1):2*row_zone_height,1:row_zone_width);
row_zone3=image((2*row_zone_height+1):end,1:row_zone_width);
column_zone1_features=lineclassifier(column_zone1);
column_zone2_features=lineclassifier(column_zone2);
column_zone3_features=lineclassifier(column_zone3);
row_zone1_features=lineclassifier(row_zone1);
row_zone2_features=lineclassifier(row_zone2);
row_zone3_features=lineclassifier(row_zone3);
euler=bweuler(image);
features=[column_zone1_features;column_zone2_features;column_zone3_features;row_zone1_features;row_zone2_features;row_zone3_features];
features=[reshape(features',numel(features),1);euler];
stats=regionprops(bwlabel(image),'all');
skel_size=numel(image);
eccentricity=stats.Eccentricity;
extent=stats.Extent;
orientation =stats.Orientation;
regional_features=[eccentricity;extent;orientation];
Undefined function or variable 'discourser'.
Error in feature_extractor_2d (line 7) image=discourser(image);
Error in f (line 2) n = feature_extractor_2d(x);
sorry for the error I added total project file

Sign in to comment.

 Accepted Answer

x=cell(1,278);
n=cell(1,279);
for j=1:279
cellRef = sprintf('A%d:BC%d',j,j);
x{j} = imread(sprintf('E:/telugu sep/2/(%d).jpg',j))
n{j} = feature_extractor_2d(x{j});
xlswrite('2.xls',n{j},'myResult',cellRef);
end

More Answers (0)

Categories

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!