how to save edges in vector

I'm trying to save the edges in vector in .mat file how can i do that?

2 Comments

how do you want the edges to be represented?
zero and one

Sign in to comment.

 Accepted Answer

Suppose you have just done edge detection on an image, and suppose the name of the output matrix is EdgeMatrix . Then you can do
EdgeVector = EdgeMatrix(:);
save EdgeMat.mat EdgeVector

6 Comments

ok but then how can i classify the edge?
You do not need to save in a .mat file to do classification.
You should probably be creating an array of values, with one column for each image, and using the neural network toolbox. To start you off I recommend using
nntool
no i don't need to used NN we have to classify it in SVM so what i'm trying to do to detect the edge and save it in .mat file then classify it but i don't know how to classify the edge
Imagine that you have a directory of image files.
Imagine further that the first letter of the file name is the class that the image belongs to. For example A_Image17.bmp belonging to group 'A' . Then,
projectdir = "Directory that image files are in";
image_extension = '*.bmp';
dinfo = dir( fullfile(projectdir, image_extension) );
num_file = length(dinfo);
for K = 1 : num_file
this_name = dinfo(K).name;
this_file = fullfile(projectdir, this_name);
this_image = imread(this_file);
Edge_Matrix = Detect_Edges_Of_Image(this_image);
EdgeVector = Edge_Matrix(:);
AllEdges(K, :) = EdgeVector;
this_target = this_name(1);
Targets{K} = this_target;
end
Now you can
SVMMdl = fitcsvm(AllEdges, Targets);
I got accuracy 68% do you know how can i improve the accuracy?!
Use a different Classification method, or experiment with different kernels, or choose a different set of features.
SVM on detected edges might not be a useful approach at all.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!