How to find the variance of an image?

75 vues (au cours des 30 derniers jours)
sachin
sachin le 12 Sep 2014
Commenté : Image Analyst le 25 Mar 2018
i try to find the variance by var function but it shoew the error. I = imread('eight.tif'); var(I)

Réponse acceptée

David Young
David Young le 12 Sep 2014
var requires a double or single argument. This will work:
img = double(imread('eight.tif'));
v = var(img);
But note that will give a vector, with one value for the variance of each column of the image. To get the variance of all the pixels in the image, you'll need
v = var(img(:));

Plus de réponses (3)

Dheeraj Kuamr Gupta
Dheeraj Kuamr Gupta le 2 Avr 2017
close all; clear all; clc; I = imread('C:\Users\anubh\Pictures\koala.jpg'); A=rgb2gray(I); [r,c]=size(A) b=r*c; s=0; s=sum(sum(A)); mean=a/b; display(mean); d=(A- mean); display(d);

Morteza Hajitabar Firuzjaei
This code calculates the variance of a RGB image but it's not standard variance, see below:
%------------------------------------------
close all;
clear all;
clc;
I = imread('b.png');
blockSize = [6 6];
varFilterFunction = @(theBlockStructure) var(double(theBlockStructure.data(:)));
blockyImagevar = blockproc(I, blockSize, varFilterFunction);
varianceImage=blockyImagevar(:);
display(varianceImage);
%---------------------------------------
Morteza Hajitabar Firuzjaei

Komal Gaikwad
Komal Gaikwad le 25 Mar 2018
how to display the variance of image in command box
  1 commentaire
Image Analyst
Image Analyst le 25 Mar 2018
Leave off the semicolon, or use disp() or fprintf().

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by