Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
NOMALIZE THE IMAGE

Subject: NOMALIZE THE IMAGE

From: mops zaki

Date: 24 May, 2010 10:56:05

Message: 1 of 12

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');
%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

Subject: NOMALIZE THE IMAGE

From: Wayne King

Date: 24 May, 2010 11:34:06

Message: 2 of 12

"mops zaki" <zaki_achi@hotmail.com> wrote in message <htdm05$kgj$1@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');
> %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

Subject: NOMALIZE THE IMAGE

From: Sean

Date: 24 May, 2010 11:42:20

Message: 3 of 12

"mops zaki" <zaki_achi@hotmail.com> wrote in message <htdm05$kgj$1@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');
> %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(:)) ;

The mean of a vector is always going to be a scalar. What else would you expect?
Is this what you're trying to do?
http://bigwww.epfl.ch/demo/jlocalnormalization/index.html
 
If so; you're not going to want the mean of the whole image(:) but rather local means.

Also note 'sigma' is a built-in function

Subject: NOMALIZE THE IMAGE

From: mops zaki

Date: 24 May, 2010 11:47:05

Message: 4 of 12

"Wayne King" <wmkingty@gmail.com> wrote in message <htdo7e$ej4$1@fred.mathworks.com>...
> "mops zaki" <zaki_achi@hotmail.com> wrote in message <htdm05$kgj$1@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');
> > %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....

Subject: NOMALIZE THE IMAGE

From: mops zaki

Date: 24 May, 2010 11:50:28

Message: 5 of 12

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <htdoms$ftr$1@fred.mathworks.com>...
> "mops zaki" <zaki_achi@hotmail.com> wrote in message <htdm05$kgj$1@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');
> > %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(:)) ;
>
> The mean of a vector is always going to be a scalar. What else would you expect?
> Is this what you're trying to do?
> http://bigwww.epfl.ch/demo/jlocalnormalization/index.html
>
> If so; you're not going to want the mean of the whole image(:) but rather local means.
>
> Also note 'sigma' is a built-in function


thanx sean...but i want mean of entire image...becuze this mean image would be subractes from original image....

zaki

Subject: NOMALIZE THE IMAGE

From: Steven Lord

Date: 24 May, 2010 13:23:06

Message: 6 of 12


"mops zaki" <zaki_achi@hotmail.com> wrote in message
news:htdovp$4eo$1@fred.mathworks.com...
> "Wayne King" <wmkingty@gmail.com> wrote in message
> <htdo7e$ej4$1@fred.mathworks.com>...
>> "mops zaki" <zaki_achi@hotmail.com> wrote in message
>> <htdm05$kgj$1@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@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

Subject: NOMALIZE THE IMAGE

From: mops zaki

Date: 24 May, 2010 13:48:07

Message: 7 of 12

"Steven Lord" <slord@mathworks.com> wrote in message <htdujg$c8b$1@fred.mathworks.com>...
>
> "mops zaki" <zaki_achi@hotmail.com> wrote in message
> news:htdovp$4eo$1@fred.mathworks.com...
> > "Wayne King" <wmkingty@gmail.com> wrote in message
> > <htdo7e$ej4$1@fred.mathworks.com>...
> >> "mops zaki" <zaki_achi@hotmail.com> wrote in message
> >> <htdm05$kgj$1@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@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

Subject: NOMALIZE THE IMAGE

From: Steven Lord

Date: 24 May, 2010 14:07:20

Message: 8 of 12


"mops zaki" <zaki_achi@hotmail.com> wrote in message
news:hte02n$jck$1@fred.mathworks.com...
> "Steven Lord" <slord@mathworks.com> wrote in message
> <htdujg$c8b$1@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@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

Subject: NOMALIZE THE IMAGE

From: Walter Roberson

Date: 24 May, 2010 14:14:55

Message: 9 of 12

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
)

Subject: NOMALIZE THE IMAGE

From: ImageAnalyst

Date: 24 May, 2010 14:43:59

Message: 10 of 12

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);

Subject: NOMALIZE THE IMAGE

From: ImageAnalyst

Date: 24 May, 2010 15:15:00

Message: 11 of 12

I'm wondering why you call this "normalize" though. Subtracting the
mean just shifts everything, it doesn't normalize. To normalize you'd
have to scale things somehow, typically by dividing something by
something else. Depends on what kind of normalization you want. What
do you REALLY want to do?

Subject: NOMALIZE THE IMAGE

From: mops zaki

Date: 26 May, 2010 06:23:37

Message: 12 of 12

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <0a75edc3-2894-498d-8e1a-11b9c73dceaa@q23g2000vba.googlegroups.com>...
> I'm wondering why you call this "normalize" though. Subtracting the
> mean just shifts everything, it doesn't normalize. To normalize you'd
> have to scale things somehow, typically by dividing something by
> something else. Depends on what kind of normalization you want. What
> do you REALLY want to do?



thanx sir for ur support....
subtraction is on of its step.....
THIS IS THE CODE THAT IS USE FOR NORMALIZATION.....WAt i have done wrong in it..

M=mean(mean(I5));
V=var(double(image(:)));
Mn=100;
Vn=255;
if I5(x,y)<M
   A=(I5(x,y)-M)^2;
   A1=double(A);
   I6=Mn+sqrt(A1*(Vn/V));
   figure(3),imshow(I6),title('normalized image');
  else
       A=(I5(x,y)-M)^2;
       A1=double(A);
       I6=Mn-sqrt(A1*(Vn/V));
       figure(3),imshow(I6),title('normalized image');
end

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us