to make the rectangle move over the image

조회 수: 2 (최근 30일)
ramya raj
ramya raj 2011년 8월 10일
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
Walter Roberson
Walter Roberson 2011년 8월 20일
duplicate is at http://www.mathworks.com/matlabcentral/answers/13866-move-rectangle-over-te-image

댓글을 달려면 로그인하십시오.

답변 (4개)

Jason
Jason 2011년 8월 10일
You can use imrect and use the mouse to size and move. It returns the position and size.
h = imrect;
pos = h.getPosition();
Jason

Image Analyst
Image Analyst 2011년 8월 10일
How about using rbbox()? It lets your user draw a box. There's sample code in its help.

ramya raj
ramya raj 2011년 8월 20일
the rectangle can be created by using rectangle function
which take the syntax of rectangle(x,y,w,h) x - x coordinate y - y coordinate w - width of the rectangle h - height of the rectangle

Walter Roberson
Walter Roberson 2011년 8월 20일
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.

Community Treasure Hunt

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

Start Hunting!

Translated by