MATLAB: How can calculate variance mean median for each band in 4 band image

digital image processingImage Processing Toolbox

i want to calculate the mean, mode, median, minimum, maximum, variance and standard deviation for each band of the provided image..Firstly, imgband1 = img(:,:,1); imgband2 = img(:,:,2); imgband3 = img(:,:,3); imgband4 = img(:,:,4) ı did that. is it true ? Can i divide the bands? after that,mean2 = mean2(imgband2) mean1 = mean2(imgband1) ı wrote them and here is a result but band3 and band4 there is an error ''Subscript indices must either be real positive integers or logicals.'' what will ı do??? thanks from now…

Best Answer

DON'T DO THIS:
mean2 = mean2(imgband2)
mean2() is a built-in function. You should not use it as the name for one of your variables unless you want to have major problems, like you're having. Call it something else.