필터 지우기
필터 지우기

Image Processing

조회 수: 1 (최근 30일)
harjan
harjan 2011년 9월 14일
답변: heba ahmed 2020년 2월 23일
Hi 2 all,
I have one formula for finding moments But i could not know how to proceed further i.e) how to write matlab code for this.Anyone can clarify this? Please send ur suggestion....
imagemoment=summation(imagepixel(i,j)*(x-x')2) / summation(imagepixel(i,j))
summation will be perfformed from 1 to 8
My code:
im=imread('image.jpg'); %binary image of 256x256
u1=xcos(0)+ysin(0);
for i=1:256
for j=1:256
for k=1:8
for l=1:8
sigma(k,l)=im(k,l)*u1; %doubtful statement
end
end
end
end
%here sigma value must be the summation of 64 values that means in x axis 8 values and y axis 8 values(8x8 block) How to perform this cumulative addition Please post how to perform basic summation Thx in advance........
im1=
x=1 to 8
x'=summation(imagepixel*x) / summation(image pixel)
i,j varies from 1 to 8
  댓글 수: 13
Jan
Jan 2011년 9월 20일
Please write a comment to proecsm's answer. Does it solve your problem? If not, why? What modifications are needed?
harjan
harjan 2011년 9월 20일
Yes I got some idea about how to perform summation.But still i need some clarification regarding that....
If i use mean() or var() to findout mean and sigma values then how to proceed it?
First divide the image using mat2cell
Then Apply the mean and var for each matrix
But How to code this
I have the sample code that is,
a=8;
b=8; %window size
x=size(image,1)/a;
y=size(image,2)/b;
m=a*ones(1,x); n=b*ones(1,y);
I=mat2cell(image,m,n);
sigma=var();%how to code this
Please post ur ideas.....

댓글을 달려면 로그인하십시오.

채택된 답변

bym
bym 2011년 9월 18일
for each 8x8 block, you will want to calculate:
im = rand(8)>.5; % generate image data
xbar = 4.5; % mean x
ybar = xbar; % mean y
im2moment = zeros(8); % allocate memory
for c = 1:8
for r = 1:8
im2moment(r,c) = (r-ybar).^2*(c-xbar).^2*im(r,c);
end
end
imagemoment = sum(sum(im2moment))/sum(sum(im));
  댓글 수: 8
harjan
harjan 2011년 9월 23일
Thanks a lot sir.........
harjan
harjan 2011년 9월 30일
Hello Sir,
I have one doubt regarding for loop.I have 256x256 image then after some operations performed, it would produce 32x32 size output(that means by analysing 8x8 values it will show a singular value 1) How it could be done?Can i try it with mat2cell? But i need some information about mat2cell in depth Please post your suggetions.
My sample code
im=imread('flower.png') %256x256 image
for x=1:8
for y=1:8
im1(x,y)=im(x,y)*cos(0)+im(x,y)*sin(0);
end
end
My question is how to iterate this loop upto 256 values?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

heba ahmed
heba ahmed 2020년 2월 23일
b=uint8(zeros(256,256));
>> [i j]=size(b);
>> for i=1:256 for j=1:256 b(i,j)=i;
end
end
>> imshow(b,[8]);

Community Treasure Hunt

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

Start Hunting!

Translated by