move rectangle over te image
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Walter Roberson
el 20 de Ag. de 2011
Duplicate is at http://www.mathworks.com/matlabcentral/answers/13444-to-make-the-rectangle-move-over-the-image
Respuestas (2)
David Young
el 17 de Ag. de 2011
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 comentarios
Walter Roberson
el 17 de Ag. de 2011
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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!