フィルターのクリア

move rectangle over te image

2 ビュー (過去 30 日間)
ramya raj
ramya raj 2011 年 8 月 17 日
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
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
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) ));

Walter Roberson
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.

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by