0

I am working on imrect function in matlab to display canny and sobel edge of ROI of imrect rectangle .
Actually I have two axis in my matlab gui. In one axis I am displaying user selected image and placing initial rectangle using imrect function on it. correspondingly to the imrect rectange I am displaying canny edge or sobel edge on axis two. Everything is fine till now.
Now I want user to drag or resize the rectangle then automatically I want to dispaly the latest rectangle canny and sobel edges on axis 2.

How to find imrect rectangle position changed or not?

Can any one help me. If any web link will help please drop that.

Shai
  • 111,146
  • 38
  • 238
  • 371
saimadhu.polamuri
  • 4,439
  • 2
  • 24
  • 21

1 Answers1

4

You can use the addNewPositionCallback method to add your own callback function to be executed whenever the rectangle changes its position.

First, you need to create a function to be called with the new rectangle position:

function myFunc( newRect )
fprintf(1, 'New rect position = [%d %d %d %d]\n', newRect );

Now you can register the function with imrect:

rHandle = imrect(); %// create the interactive rectangle
addNewPositionCallback( rHandle, @myFunc ); %// register function myFunc to be called when rect is changed
Shai
  • 111,146
  • 38
  • 238
  • 371