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
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Diwakar Diwakar
2023-6-11
移动:Image Analyst
2023-6-11
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 个评论
更多回答(1 个)
Image Analyst
2023-6-11
"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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Pattern Recognition and Classification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!