function [IsNOKparts] = NOKparts(imds)

    dataFilenames = imds.Files;
    nFiles = numel(dataFilenames);
    Ipartleft = zeros(13);
    Ipartright = zeros(13);
    Ipartavgright = zeros(1,nFiles);
    Ipartavgleft = zeros(1,nFiles);
    IsNOKparts = zeros(1,nFiles);
    IsNOKpartstest = zeros(1,nFiles);
    threshright = 25;
    threshleft = 150;

    %detekce chybejicich dilu a oderek    
for k = 1:nFiles
    I = readimage(imds,k);

    for i = 1:13
        for j = 1:13
            Ipartleft(i,j) = I(155+i,30+j);
            Ipartright(i,j) = I(280+i,744+j);
        end
    end
%detekce oderek
   Iabrasion = imcrop(I,[714 181 5 209]);
   abrasion = Iabrasion<50;

    Ipartavgleft(k) = mean(Ipartleft,'all');
    Ipartavgright(k) = mean(Ipartright,'all');

    if (Ipartavgleft(k) > threshleft) | (Ipartavgright(k) > threshright)
        IsNOKparts(k) = 1;
    end
    if  ~IsNOKparts(k) 
        if sum(abrasion,'all')>34     
            IsNOKparts(k) = 1;
        end
    end
end

end
