Problem using extractLBPFeatures because the output cant be write to a matrix
Afficher commentaires plus anciens
I have a bunch of images I want to extract features of and I'm using different kinds of functions like mean, entropy, and graycoprops but I also want to use extractLBPFeatures, all de data is written to column vectors or matrix that I preallocate after using zeros, but when I tried to use the same for the features of extractLBPFeatures I have this error Unable to perform assignment because the left and right sides have a different number of elements. The dimensions of the output are always 1x10 row vectors and the number of files is 49 so I create a 49x10 matrix
my code
% se busca el directorio donde estan todas las imagenes a analizar
imagenes1 = imageDatastore('C:\Users\mi-ck\OneDrive\Escritorio\clases_matlab\jorge\NORMAL_DCI\NORMAL_DCI');
% se prelocaliza la memoria de todas las variables que se utilizaran para
% guardar los datos del analisis
[l,a] = size(imagenes1.Files);
media = zeros(l,1);
desviacion = zeros(l,1);
entropia = zeros(l,1);
% se ejecuta un ciclo for donde se extraen las siguientes propiedades de
% cada imagen: media, desviacion estandar, entropia, contraste,
% correlacion, energia y homogeneidad
localBinary = zeros(l,10);
for i = 1:l
imagen = readimage(imagenes1,i);
%imagenrecortada = imcrop(imagen,[130 109 670 600]);
media(i) = mean(imagen(:));
desviacion(i) = std(double(imagen(:)));
entropia(i) = entropy(imagen);
propiedades(i) = graycoprops(imagen);
extractLBPFeatures(imagen,"Upright",false)
%imshow(imcrop(imagen,[164 109 787 629]))
end
example of the output

Réponses (1)
Image Analyst
le 12 Déc 2021
1 vote
We can't run images, only code as text.
And also attach any files/images we need to load at run time. I'll check back later.
graycoprops() does not return a scalar so you can't stuff it into propiedades(i).
4 commentaires
Miguel Angel Manuel Espindola Gleason
le 12 Déc 2021
Image Analyst
le 12 Déc 2021
What is the name of that structure? I don't see it. Post your latest code.
Is it working now?
Miguel Angel Manuel Espindola Gleason
le 12 Déc 2021
Image Analyst
le 12 Déc 2021
This seems to work fine:
clc; % Clear the command window.
fprintf('Beginning to run %s.m ...\n', mfilename);
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
lineWidth = 3;
% se busca el directorio donde estan todas las imagenes a analizar
% imagenes1 = imageDatastore('C:\Users\mi-ck\OneDrive\Escritorio\clases_matlab\jorge\NORMAL_DCI\NORMAL_DCI');
imagenes1 = imageDatastore(fullfile(pwd, '*.png'));
% se prelocaliza la memoria de todas las variables que se utilizaran para
% guardar los datos del analisis
numImages = length(imagenes1.Files);
media = zeros(numImages,1);
desviacion = zeros(numImages,1);
entropia = zeros(numImages,1);
% se ejecuta un ciclo for donde se extraen las siguientes propiedades de
% cada imagen: media, desviacion estandar, entropia, contraste,
% correlacion, energia y homogeneidad
localBinary = zeros(numImages,10);
for i = 1: numImages
imagen = readimage(imagenes1,i);
[rows, columns, numberOfColorChannels] = size(imagen);
if numberOfColorChannels == 3
imagen = rgb2gray(imagen);
end
%imagenrecortada = imcrop(imagen,[130 109 670 600]);
imshow(imagen, []);
drawnow;
media(i) = mean2(imagen);
desviacion(i) = std2(double(imagen));
entropia(i) = entropy(imagen);
% Put GLCM measurements into a structure array.
propiedades(i) = graycoprops(imagen);
lbp = extractLBPFeatures(imagen,"Upright",false)
%imshow(imcrop(imagen,[164 109 787 629]))
end
Catégories
En savoir plus sur Object Detection dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
