Problem 1 images: b=imread('5_67-gray.jpg'); stats(b) % gather statistics c=extract435(b,193,182,300,250); stats(c) % gather statistics figure(1),imshow(c) % Now find the mode... [counts,x]=imhist(c); % determine histogram info [m,index]=max(counts); % index = the index of the max value of the histogram % the grayscale value that appears most would then be index-1 (since MATLAB % indices start at 1, but grayscale values start at 0 d=uint8(zeros(size(c))); % create an image of zeros the same size as c d(c>200)=1;,d(c<75)=1; % set some of the values in D to 1 figure(2),imshow(d,[]) sum(d(:)) % this sum will be the total number of 1s in the image Problem 2: Given Decision Boundary Problem 2: My improved decision boundary: load USNK_hand.dat s=USNK_hand; USf1=s(1:500,3);,USf2=s(1:500,4); NKf1=s(501:end,3);,NKf2=s(501:end,4); figure(3),plot(USf1,USf2,'ro',NKf1,NKf2,'b+') xlabel('Feature 1: largest extent of hand (cm)') ylabel('Feature 2: area of palm (cm^2)') grid on, legend('US','NK'),title('Scatter Plot: Area of Palm vs. Largest Extent of Hand'),hold on % now add the given decision boundary f1=6.5:0.1:9; b= -15*f1 + 152.5; plot(f1,b,'k','linewidth',2) hold off axis([6.5 10 25 45]) % Test of the given decision boundary for k=1:775 testval = s(k,4) + 15* s(k,3) -152.5; if testval >= 0 % indicates US s(k,2)=1; else s(k,2)=2; % indicates NK end end errors = length(find(s(:,1) ~= s(:,2))) accuracy=(775-errors)/775 * 100 % now test my improved decision boundary s=USNK_hand; for k=1:775 testval = s(k,4)-33; if testval >= 0 s(k,2)=1; else s(k,2)=2; end end errors = length(find(s(:,1) ~= s(:,2))) accuracy=(775-errors)/775 * 100 figure(4),plot(USf1,USf2,'ro',NKf1,NKf2,'b+') xlabel('Feature 1: largest extent of hand (cm)') ylabel('Feature 2: area of palm (cm^2)') grid on, legend('US','NK'),title('Scatter Plot: Area of Palm vs. Largest Extent of Hand'),hold on % put my new decision boundary on the scatter plot f1=6.5:0.1:10; b= 33*ones(size(f1)); plot(f1,b,'k','linewidth',2) hold off