-4

Firstly, I want to find standard deviation of this image:

enter image description here

Secondly, I want to find standard deviation of all lines in the image.

But at the first step, somethings going wrong and I see this:

>> A = imread('C:\Users\PC\Desktop\deneme.jpg');
>> std (A);
Error using var (line 65)
First argument must be single or double.

Error in std (line 38)
y = sqrt(var(varargin{:}));

line 65: error(message('MATLAB:var:integerClass'));
line 38: y = sqrt(var(varargin{:}));

How can I solve this problem and what is the code of finding standard deviation of all lines in this image?

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
volkan
  • 195
  • 7

1 Answers1

5

The error is very explicit:

First input argument must be single or double.

This happens because A is of type uint8. The input to std has to be floating point (single or double).

So: convert to double, and optionally divide by 255 to normalize values to the interval between 0 and 1:

std(double(A)/255)

Note that the above gives the standard deviation of each column. If you want the stantard deviation of the image considered as a whole, linearize to a column vector first:

std(double(A(:))/255)
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147