to make the rectangle move over the image
조회 수: 2 (최근 30일)
이전 댓글 표시
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
2011년 8월 20일
duplicate is at http://www.mathworks.com/matlabcentral/answers/13866-move-rectangle-over-te-image
답변 (4개)
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
댓글 수: 0
Image Analyst
2011년 8월 10일
How about using rbbox()? It lets your user draw a box. There's sample code in its help.
댓글 수: 0
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!