My work is on extracting features of Disease image to extract exact region of Interest of Disease which is the best features algorithm to be used
6 views (last 30 days)
Show older comments
Harika KM
on 11 Jun 2023
Answered: Image Analyst
on 11 Jun 2023
extracting features for exact region of Interest in Disease fruit
how to divide testing and training data which is the best algorithm machine learning for feature extracting and Classification of Disease .
0 Comments
Accepted Answer
Diwakar Diwakar
on 11 Jun 2023
Moved: Image Analyst
on 11 Jun 2023
To extracting features from disease images and identifying the exact region of interest (ROI), there are several algorithms and techniques you can consider.
CNNs have been highly successful in image analysis tasks, including feature extraction and classification. They learn hierarchical representations of images and can identify relevant features in the ROI.
Instead of using pre-defined feature extraction algorithms, you can use deep learning models such as autoencoders or pre-trained models like VGG16 or ResNet to learn features directly from the images.
This code will help you to understand the basic concept:
% Load pre-trained VGG16 model
net = vgg16;
% Set the path to your disease image dataset
datasetPath = 'path_to_your_dataset';
% Set the percentage of data to be used for testing
testPercentage = 0.2;
% Load disease image dataset
imds = imageDatastore(datasetPath, 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
% Split dataset into training and testing sets
[trainImds, testImds] = splitEachLabel(imds, testPercentage, 'randomized');
% Extract features from training set using VGG16
featuresTrain = activations(net, trainImds, 'fc7', 'MiniBatchSize', 32, 'OutputAs', 'columns');
% Extract features from testing set using VGG16
featuresTest = activations(net, testImds, 'fc7', 'MiniBatchSize', 32, 'OutputAs', 'columns');
% Get training labels
trainLabels = trainImds.Labels;
% Get testing labels
testLabels = testImds.Labels;
% Train a classifier on the extracted features
classifier = fitcecoc(featuresTrain, trainLabels);
% Make predictions on the testing set
predictedLabels = predict(classifier, featuresTest);
% Evaluate the accuracy of the classifier
accuracy = mean(predictedLabels == testLabels);
fprintf('Accuracy: %.2f%%\n', accuracy * 100);
In this code, we use the VGG16 model to extract features from the images in the training and testing sets. The extracted features are then used to train a multi-class classifier (fitcecoc) and make predictions on the testing set. The accuracy of the classifier is calculated and displayed.
Moreover, the choice of the best machine learning algorithm for feature extraction and classification depends on various factors such as the complexity of the problem, the size and quality of your dataset, and the computational resources available.
0 Comments
More Answers (1)
Image Analyst
on 11 Jun 2023
"how to divide testing and training data"
Try randsample
help randsample
You could also use randperm
help randperm
I'm not really sure how they're different, if at all.
0 Comments
See Also
Categories
Find more on Pattern Recognition and Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!