Hello,
I am trying to extract features from a segmented breast lesion. However I am getting an error when I try to use the regionprops function. Please find the code below:
clc;clear;close all% Specify the folder where the files live.
myFolder = 'C:\Users\morteza\Desktop\Udemy Courses\Deep Learning A-Z\P16-Convolutional-Neural-Networks (1)\Convolutional_Neural_Networks\Images_Malignant\training_set\Benign\Images';% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isfolder(myFolder) errorMessage = sprintf('Error: The following folder does not exist:\n%s\nPlease specify a new folder.', myFolder); uiwait(warndlg(errorMessage)); myFolder = uigetdir(); % Ask for a new one.
if myFolder == 0 % User clicked Cancel
return; endend% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.jpg'); % Change to whatever pattern you need.
theFiles = dir(filePattern);for k = 1 : length(theFiles) baseFileName = theFiles(k).name; fullFileName = fullfile(theFiles(k).folder, baseFileName); fprintf(1, 'Now reading %s\n', fullFileName); % Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
r = im2double((imread(fullFileName)));try r=rgb2gray(r);endJ = imnoise(r,'salt & pepper',0.02);c=medfilt2(J);b= adapthisteq(c);% b = medfilt2(r1);
hy = fspecial('sobel');hx = hy';Iy = imfilter(double(b), hy, 'replicate');Ix = imfilter(double(b), hx, 'replicate');gradmag = sqrt(Ix.^2 + Iy.^2);L = watershed(gradmag);Lrgb = label2rgb(L);se = strel('disk', 20);Io = imopen(b, se);Ie = imerode(b, se);Iobr = imreconstruct(Ie, b);Ioc = imclose(Io, se);Iobrd = imdilate(Iobr, se);Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));Iobrcbr = imcomplement(Iobrcbr);fgm = imregionalmax(Iobrcbr);% figure
Y = imclearborder(fgm);stats1 = regionprops(Y,'Area','Circularity','Solidity','Eccentricity', 'EquivDiameter','EulerNumber','MajorAxisLength','MinorAxisLength','Perimeter');area=stats1.Area;circularity=stats1.Circularity;solidity=stats1.Solidity;eccentricity=stats1.Eccentricity;equivdiameter=stats1.EquivDiameter;eulernumber=stats1.EulerNumber;major=stats1.MajorAxisLength;minor=stats1.MinorAxisLength;perimeter=stats1.Perimeter;p(k,:)=[area,circularity,solidity,eccentricity,equivdiameter,eulernumber,major,minor,perimeter];
I get the following error message:
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
Error in gf (line 84)
area=stats1.Area;
Best Answer