I've changed the image format to a tiff file to suit my problem better, however I am still receiving the same error.
Error with image analysis
1 view (last 30 days)
Show older comments
I've been trying to get this script working, but I don't know how. What it should be able to do is make the image black and white and be able to pick out the centroid of the object in the image.
i = imread('343A #1.tif');
j = size(i);
for k = 1:j(1)
for l = 1:j(2)
if i(k,l,1) > 160 & i(k,l,2) > 160
d(k,l) = 1;
d(k,l) = 0;
label = bwlabel(d);
[label,num] = bwlabel(d,4);
stats = regionprops(label,'basic');
max_area = max([stats.Area]);
biggrain = find([stats.Area]== max_area);
??? Attempted to access i(2,51,2); index out of bounds because size(i)=[256,64,1].
Error in ==> TestingCentroid3 at 10 if i(k,l,1) > 160 & i(k,l,2) > 160
i is apparently a 2d image. what is j (size(i))?
d = I > 160; %don't name your variables i,j as they are the sqrt(-1)
Find more on Convert Image Type 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!