필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

to move a virtual window

조회 수: 1 (최근 30일)
ramya raj
ramya raj 2011년 9월 23일
마감: MATLAB Answer Bot 2021년 8월 20일
hai
i have a image i have to move a window of height 700 and width 30 over the image continuously from left to right i have used the following code by i can't get the answe
Actually i am having a 605X700 image and a window of size 30X700 first i have to go from 1-30 then 2-31 and 3-32 and 4-33 and so on and the code i have used is below
a=1;
b=30;
for i=1:700
for j=a:b
if(b<=700)
yvalue=sum(fmap1(i,j));
a=a+1;
b=b+1;
end
end
end
please help me thanks in advance
  댓글 수: 1
Jan
Jan 2011년 9월 23일
What do you want to calculate? I assume "fmap1(i,j)" is a scalar value, so why do you apply a SUM?

답변 (2개)

Walter Roberson
Walter Roberson 2011년 9월 23일
Looks to me as if you should be using blockproc() or blkproc()
  댓글 수: 2
ramya raj
ramya raj 2011년 9월 26일
i have already used blkproc() function while using blkproc() i am getting a 1X23 matrix but actually i want a 1X670 around matrix it can be possible only if i use the for loop and the for loop that i have used is mentioned by me above but im not getting the correct answer on sing the for loop there is a small mistake in it but i can't find it
Walter Roberson
Walter Roberson 2011년 9월 26일
Sounds like you failed to specify the overlap to blkproc()
Your code is overwriting "yvalue" each time through the loop, so at the end of the loops, yvalue will contain only the result for the very last iteration.

Jan
Jan 2011년 9월 26일
I cannot find out, what you want to calculate. If you want a running mean, this methods solves the problem:
fmap1 = rand(605, 700);
b = 30;
yvalue = zeros(605 - b, 700);
for i = 1:605 - b
yvalue(i, :) = sum(fmap1(i:i + b - 1, :));
end
This is not efficient, because most of the rows are added repeatedly. But it is as near to your original code as possible. If you want something else, you have the chance to explain it here.
  댓글 수: 2
ramya raj
ramya raj 2011년 9월 27일
actually i have to calculate the sum of pixel values inside a window of size 30X700 for that i have to gradually move the window over the image of size 605X700 first i have to calculate the sum of pixel values for first 1-30pixels second sum for 2-31 pixels and third 3- 32 pixels extra up to 700 pixels
Jan
Jan 2011년 9월 27일
The solution I have posted does what you want, but along the first dimension, while you want it along the 2nd dimension. I think, you are able to convert my example accordingly.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by