Hello,
I have an image. I want to divide the image into 100 frames and analyze each frame separately. Please find my code below:
img = imread('1F1.jpg');k = 1; for j = 1: 100 dblSubtractedImage = img(j) - img(k); s = dblSubtractedImage*5; L = mat2gray(s); imshow(L); im = imclearborder(255-imclearborder(255-s)); hc = sum(im,2); mask = hc >= 14500; fr = find(mask, 1, 'first'); lr = find(mask, 1, 'last'); cr = im(fr:lr, :); D = std2(cr); meanIntensityValue = mean2(cr); % imshow(cr)
K = mat2gray(cr); min_image = min(K(:)); max_image = max(K(:)); % figure
imshow(K) [rows, columns, numberOfColorBands] = size(K); if numberOfColorBands > 1 grayImage = K(:, :, 2); end binaryImage = grayImage~= 40; area2 = sum( binaryImage,'all'); end AverageArea = (sum(area2))/100;AverageStandardDeviation = (sum(D))/100;AverageIntensityValue = (sum(meanIntensityValue))/100;
The first frame is used as a reference. The first frame is subtracted from all the other frames subsequently. The resulting images are then masked using a threshold which is shown above. Few other parameters such as the mean, standard deviation and the area of each of the resulting image are found. At the end of the for loop, the average value of the parameters above are found. However, I am getting the error message below. Any help would be appreciated. Thank you.
>> f
Index exceeds the number of array elements (0).
Error in mat2gray (line 38)
if limits(2)==limits(1) % Constant Image
Error in f (line 17)
K = mat2gray(cr);
Best Answer