From: Steven Lord on

"mops zaki" <zaki_achi(a)hotmail.com> wrote in message
news:htdovp$4eo$1(a)fred.mathworks.com...
> "Wayne King" <wmkingty(a)gmail.com> wrote in message
> <htdo7e$ej4$1(a)fred.mathworks.com>...
>> "mops zaki" <zaki_achi(a)hotmail.com> wrote in message
>> <htdm05$kgj$1(a)fred.mathworks.com>...
>> > i have to do normalization...for it first i have to calculate mean and
>> > variance of the image
>> > i use M = mean(I5(:)) ; to calculate mean...but the size of image
>> > reduce to 1x1 after mean.. WAT I HAVE DONE WRONG
>> >
>> > MY FULL CODE IS..
>> > clear all
>> > image=imread('0001hv1.bmp');

You should change this variable name; IMAGE is a function in MATLAB, and you
may want to use it later on in your code.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/image.html

>> > %Designing guasian filter%%%%%%%%%%%%%%%%%%(LOW PASS)
>> > sigma=0.8;
>> > H=fspecial('gaussian',[5 5],sigma);
>> > I5=imfilter(image,H);
>> > figure(2),imshow(I5);
>> > M = mean(I5(:)) ;
>> >
>> > HELP ME PLZ
>>
>> Hi, did you just intend to calculate the mean of each column in the
>> image? Then, just enter:
>>
>> M = mean(I5);
>>
>> Your line M = mean(I5(:)); is equivalent to M = mean(mean(I5));
>> you're calculating the mean of the column means. That's why it's a
>> scalar.
>>
>> Wayne
>
>
> hi i want to calculate mean of whole image....ofter calulating mean i have
> to subtract the mean image from the original one....

Okay, so you've done the first half of what you wanted. Now you need to
subtract the mean _value_ (M) from the original image. If you intend
something other than the mean value when you refer to "the mean image" then
you need to clearly state what exactly you want when you use that phrase.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: mops zaki on
"Steven Lord" <slord(a)mathworks.com> wrote in message <htdujg$c8b$1(a)fred.mathworks.com>...
>
> "mops zaki" <zaki_achi(a)hotmail.com> wrote in message
> news:htdovp$4eo$1(a)fred.mathworks.com...
> > "Wayne King" <wmkingty(a)gmail.com> wrote in message
> > <htdo7e$ej4$1(a)fred.mathworks.com>...
> >> "mops zaki" <zaki_achi(a)hotmail.com> wrote in message
> >> <htdm05$kgj$1(a)fred.mathworks.com>...
> >> > i have to do normalization...for it first i have to calculate mean and
> >> > variance of the image
> >> > i use M = mean(I5(:)) ; to calculate mean...but the size of image
> >> > reduce to 1x1 after mean.. WAT I HAVE DONE WRONG
> >> >
> >> > MY FULL CODE IS..
> >> > clear all
> >> > image=imread('0001hv1.bmp');
>
> You should change this variable name; IMAGE is a function in MATLAB, and you
> may want to use it later on in your code.
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/image.html
>
> >> > %Designing guasian filter%%%%%%%%%%%%%%%%%%(LOW PASS)
> >> > sigma=0.8;
> >> > H=fspecial('gaussian',[5 5],sigma);
> >> > I5=imfilter(image,H);
> >> > figure(2),imshow(I5);
> >> > M = mean(I5(:)) ;
> >> >
> >> > HELP ME PLZ
> >>
> >> Hi, did you just intend to calculate the mean of each column in the
> >> image? Then, just enter:
> >>
> >> M = mean(I5);
> >>
> >> Your line M = mean(I5(:)); is equivalent to M = mean(mean(I5));
> >> you're calculating the mean of the column means. That's why it's a
> >> scalar.
> >>
> >> Wayne
> >
> >
> > hi i want to calculate mean of whole image....ofter calulating mean i have
> > to subtract the mean image from the original one....
>
> Okay, so you've done the first half of what you wanted. Now you need to
> subtract the mean _value_ (M) from the original image. If you intend
> something other than the mean value when you refer to "the mean image" then
> you need to clearly state what exactly you want when you use that phrase.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
>


sir it mean that I5(x,y) is my original image i want to subtract mean i.e M(M=mean(I5(:)); from my image I5...
i.eA=(I5(x,y)-M)^2;
it give nothig 1x1 is size...
reqardz zaki
From: Steven Lord on

"mops zaki" <zaki_achi(a)hotmail.com> wrote in message
news:hte02n$jck$1(a)fred.mathworks.com...
> "Steven Lord" <slord(a)mathworks.com> wrote in message
> <htdujg$c8b$1(a)fred.mathworks.com>...

*snip*

>> >> > %Designing guasian filter%%%%%%%%%%%%%%%%%%(LOW PASS)
>> >> > sigma=0.8;
>> >> > H=fspecial('gaussian',[5 5],sigma);
>> >> > I5=imfilter(image,H);
>> >> > figure(2),imshow(I5);
>> >> > M = mean(I5(:)) ;

*snip*

> sir it mean that I5(x,y) is my original image

Incorrect. Your "original image" is either the variable named image (that I
advised you to rename) or I5 -- I5(x, y) is some subset of the elements in
the image after it has been filtered.

> i want to subtract mean i.e M(M=mean(I5(:)); from my image I5...
> i.eA=(I5(x,y)-M)^2;
> it give nothig 1x1 is size...

That's correct, assuming x and y are scalars; in that case that code
operates on _one element_ of I5. If you want to operate on _all elements_
of I5 then do so.

A = I5-M;

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Walter Roberson on
mops zaki wrote:

> sir it mean that I5(x,y) is my original image i want to subtract mean
> i.e M(M=mean(I5(:)); from my image I5...
> i.eA=(I5(x,y)-M)^2;
> it give nothig 1x1 is size...

I5(x,y) is not your original image: it is one pixel out of your
individual image. Use I5 instead of I5(x,y) to do the whole array at
once. (And when that gives an error message, look for the documentation
about "array power" at
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/arithmeticoperators.html
)
From: ImageAnalyst on
mops:
One thing to be aware of is that you'll need to convert your image do
floating point if you want the difference image to be correct. If you
don't, it will stay as uint8 and it will clip values to 0 and you'll
have an incorrect image. Run this demo and you'll see what I mean:
(IMPORTANT: BE SURE TO JOIN THE "message = sprintf(...." LINE WHICH
WILL GET SPLIT INTO MULTIPLE LINES BY THE NEWSREADER!!!)

% function test()

% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;

% Read in standard MATLAB gray scale demo image.
grayImage = imread('cameraman.tif');
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

% Calculate the mean gray level of the entire image.
meanGrayLevel = mean(grayImage(:))
% Calculate the difference with the result being a uint8 image.
uint8SubtractedImage = grayImage - meanGrayLevel;
subplot(2, 2, 2);
imshow(uint8SubtractedImage, []);
title('Difference uint8 Image', 'FontSize', fontSize);
% Calculate the mean after subtraction.
% It should be zero, but it won't be.
meanGrayLeveluint8 = mean(uint8SubtractedImage(:))


% Calculate the difference with the result being a uint8 image.
dblSubtractedImage = double(grayImage) - meanGrayLevel;
subplot(2, 2, 3);
imshow(dblSubtractedImage, []);
title('Difference double Image', 'FontSize', fontSize);
% Calculate the mean after subtraction. It will be zero.
meanGrayLevelDouble = mean(dblSubtractedImage(:))

% Display results.
message = sprintf('The mean of the original uint8 image = %.2f\nThe
mean of the uint8 difference image = %.2f\nThe mean of the double
difference image = %.2f', ...
meanGrayLevel, meanGrayLeveluint8, meanGrayLevelDouble);
msgbox(message);