move rectangle over te image
조회 수: 2 (최근 30일)
이전 댓글 표시
hai
i am doing a project for locating the optic disc in matlab and i am new to matlab what i have to do is to move the rectangle over a image and calculate the sum of values inside the rectangle
now i have created a rectangle by using the rectangle function next i have slide or move the rectangle over my image
i have used while loop for that
and the rectangle is copied over the entire image but i have to just move it in the horizontal direction
here is the code that i have tried please help me
final2=edgediff./eror; figure,image((final2)); title('Feature MAP 1'); i=1; for j=10 while(i<1500) r=rectangle('position'[i,10,26.7,1135],'linewidth',2.4,'edgecolor','w'); res(i) = sum(r); i=i+26.7; end i need the code urgently please help me
댓글 수: 1
Walter Roberson
2011년 8월 20일
Duplicate is at http://www.mathworks.com/matlabcentral/answers/13444-to-make-the-rectangle-move-over-the-image
답변 (2개)
David Young
2011년 8월 17일
If you have an array A, and you want the sum of the values in a rectangle whose top and bottom are rows R1 and R2, and whose left and right are columns C1 and C2, then you can use
s = sum(sum( A(R1:R2, C1:C2) ));
댓글 수: 0
Walter Roberson
2011년 8월 17일
David's response is correct, but there are also other ways to proceed.
You could use blkproc() (older MATLAB) or blockproc() (newer MATLAB), or nlfilter() (probably a good choice for this task). Also, I gather that you could construct this in terms of using conv2() of the matrix with an N x M matrix of 1's.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!