to make the rectangle move over the image
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hai
i am new to matlab i doing a project for locating the optic disc for that i have create a rectangular window and make the window to move the image and calculate the sum of edge diff inside the window and divide that by sum of intensity inside the window
now i have created a window but i don't know how to move the rectangular window
this is my code please help me
_clc; clear all; close all; fundus=imread('D:\10mcs010\im0001.ppm'); grayImage=fundus(:,:,1);
subplot(4, 4, 1);
imshow(grayImage);
title('Original Grayscale Image');
binaryImage = grayImage > 35;
% Display the binary image.
subplot(4, 4, 2);
imshow(binaryImage);
title('Binary Image');
A=[0 0 0;0 1 0;0 0 0];
op=imopen(binaryImage,A);
subplot(4,4,3);
imshow(op);
title('open image');
clos=imopen(op,A);
subplot(4,4,4);
imshow(clos);
title('closeimage');
eror=imopen(clos,A);
subplot(4,4,5);
imshow(eror);
subplot(4,4,6);
maskedRgbImage = bsxfun(@times, fundus, cast(eror,class(fundus)));
imshow(maskedRgbImage);
title('RGB IMAGE');
g=maskedRgbImage(:,:,2);
subplot(4,4,7);
imshow(g);
title ('Green component');
subplot(4,4,8);
imv=conv2(double(g),[1 0 -1],'same');
imshow((imv));
title ('vertical image');
subplot(4,4,9);
imh=conv2(double(g),[1;0;-1],'same');
imshow(imh);
re=imh;
imwrite(re,'horizontal.tif');
title ('horizontal image');
edgesum=abs(imh)+abs(imv);
% % intens=impixel(fundus);
%
% % figure,imshow(edgesum);
% edgediff=abs(imv)-abs(imh);
im = imread('horizontal.tif');
subplot(4,4,10);
imshow(im);
r=rectangle('Position',[10,10,12,560]);
set(r,'edgecolor','w') % change the color of the rectangle to white
title('image with rectangle');_
*BOLD TEXT*
1 comentario
Walter Roberson
el 20 de Ag. de 2011
duplicate is at http://www.mathworks.com/matlabcentral/answers/13866-move-rectangle-over-te-image
Respuestas (4)
Jason
el 10 de Ag. de 2011
You can use imrect and use the mouse to size and move. It returns the position and size.
h = imrect;
pos = h.getPosition();
Jason
0 comentarios
Image Analyst
el 10 de Ag. de 2011
How about using rbbox()? It lets your user draw a box. There's sample code in its help.
0 comentarios
Walter Roberson
el 20 de Ag. de 2011
This seems to me to be a make-work project. Moving a virtual array over the data array would be much much more efficient than drawing a rectangle on the screen and figuring out what is inside the drawn portion.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!