How do I fix the Function 'subsindex' is not defined for values of class 'cell' in my code?
Show older comments
The code below returns the error 'Function 'subsindex' is not defined for values of class 'cell'.'
Error in main_lameness_algo (line 93)
if (mean(Dprev(refimage{g,1})))<((refimage{g,2})+50) && ((refimage{g,2})-50)<(mean(Dprev(refimage{g,1})))
Please how can I fix it
refimage = cell(5,3);
n = 1;
while 1
n = n+1;
filename = ['f' num2str(n) '.txt'];
[A2]=importdata(filename);
B2 = reshape(A2,[512,424]);
C2 = transpose(B2);
rowstart2 = 1;
rowstop2 = 370;
colstart2 = 50;
colstop2 = 512;
D2 = C2(rowstart2:rowstop2,colstart2:colstop2);
D2(D2<1) = 2600;
D2(D2<2000) = 2600;
filenameprev = ['f' num2str(n-1) '.txt'];
[Aprev,delimiterOut]=importdata(filenameprev);
Bprev = reshape(Aprev,[512,424]);
Cprev = transpose(Bprev);
rowstartprev = 1;
rowstopprev = 370;
colstartprev = 50;
colstopprev = 512;
Dprev = Cprev(rowstartprev:rowstopprev,colstartprev:colstopprev);
Dprev(Dprev<1) = 2600;
Dprev(Dprev<2000) = 2600;
pigtime = 0;
thresholdValue2 = 0.7;
originalImage2 = mat2gray(D2,[1600 2600]);
binaryImage2 = originalImage2 < thresholdValue2; % Bright objects will be chosen if you use >.
binaryImage2 = imfill(binaryImage2, 'holes');
binaryImage2 = bwareaopen(binaryImage2,5000); %remove blobs less than certain pixels
labeledImage2 = bwlabel(binaryImage2, 8);
blobMeasurements2 = regionprops(labeledImage2, D2, 'all');
numberOfBlobs2 = size(blobMeasurements2, 1);
if numberOfBlobs2<1
continue
end
for g = 1 : numberOfBlobs2 % Loop through all blobs (sitting pigs).
thisBlobsPixels = blobMeasurements2(g).PixelIdxList; % Get list of pixels in current blob.
refimage{g,1} = {thisBlobsPixels};
thisBlobsPixvals = blobMeasurements2(g).PixelValues; % Get list of pixels values in current blob.
refimage{g,2} = {mean(thisBlobsPixvals)};
%refimage{g,3} = {pigtime};
if (mean(Dprev(refimage{g,1})))<((refimage{g,2})+50) && ((refimage{g,2})-50)<(mean(Dprev(refimage{g,1})))
refimage{g,3} = (refimage{g,3}) + 5;
end
end
if n ==20
break
end
end
1 Comment
Rena Berman
on 7 Nov 2018
(Answers Dev) Restored edit
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic 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!