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

4 visualizaciones (últimos 30 días)
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 .

Respuesta aceptada

Diwakar Diwakar
Diwakar Diwakar el 11 de Jun. de 2023
Movida: Image Analyst el 11 de Jun. de 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.

Más respuestas (1)

Image Analyst
Image Analyst el 11 de Jun. de 2023
"how to divide testing and training data"
help randsample
RANDSAMPLE Random sample, with or without replacement. Y = RANDSAMPLE(N,K) returns Y as a column vector of K values sampled uniformly at random, without replacement, from the integers 1:N. Y = RANDSAMPLE(POPULATION,K) returns K values sampled uniformly at random, without replacement, from the values in the vector POPULATION. Y is a vector of the same type as POPULATION. NOTE: When POPULATION is a numeric vector containing only non-negative integer values, and it might have length 1, use either Y = DATASAMPLE(POPULATION,K,'Replace',false) or Y = POPULATION(RANDSAMPLE(LENGTH(POPULATION),K)) instead of Y = RANDSAMPLE(POPULATION,K). Y = RANDSAMPLE(N,K,REPLACE) or RANDSAMPLE(POPULATION,K,REPLACE) returns a sample taken with replacement if REPLACE is true, or without replacement if REPLACE is false (the default). Y = RANDSAMPLE(N,K,true,W) or RANDSAMPLE(POPULATION,K,true,W) returns a weighted sample, using positive weights W, taken with replacement. W is often a vector of probabilities. This function does not support weighted sampling without replacement. Y = RANDSAMPLE(S,...) uses the random number stream S for random number generation. RANDSAMPLE uses the MATLAB default random number stream by default. Examples: Draw a single value from the integers 1:10. n = 10; x = randsample(n,1); Draw a single value from the population 1:n, when n > 1. y = randsample(1:n,1); Generate a random sequence of the characters ACGT, with replacement, according to specified probabilities. R = randsample('ACGT',48,true,[0.15 0.35 0.35 0.15]) See also RAND, RANDPERM, RANDSTREAM. Documentation for randsample doc randsample Other uses of randsample gpuArray/randsample quantum.gate.QuantumState/randsample
You could also use randperm
help randperm
RANDPERM Random permutation. P = RANDPERM(N) returns a vector containing a random permutation of the integers 1:N. For example, RANDPERM(6) might be [2 4 5 6 1 3]. P = RANDPERM(N,K) returns a row vector containing K unique integers selected randomly from 1:N. For example, RANDPERM(6,3) might be [4 2 5]. RANDPERM(N,K) returns a vector of K unique values. This is sometimes referred to as a K-permutation of 1:N or as sampling without replacement. To allow repeated values in the selection, sometimes referred to as sampling with replacement, use RANDI(N,1,K). RANDPERM calls RAND and therefore changes the state of the random number generator that underlies RAND, RANDI, and RANDN. Control that shared generator using RNG. See also NCHOOSEK, PERMS, RAND, RANDI, RNG. Documentation for randperm doc randperm Other uses of randperm gpuArray/randperm RandStream/randperm
I'm not really sure how they're different, if at all.

Categorías

Más información sobre Pattern Recognition and Classification en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by