0

I have a sample image as below. I would like to make the square my Region of Interest and then crop out that part (square) and create a new image with it. I will be working with different images so the square won't always be at the same location in all images. So I will need to somehow detect the edges of the square.

I can not post pictures because I have 10 reputations

help me please??

Thank you very much

1 Answers1

0
cvSetImageROI(currentImage,yourSquare);
CvSize size = cvSize(width, height);
IplImage * newImage = cvCreateImage(size,8,3);
cvResize(currentImage,newImage,CV_INTER_AREA);

First you must set your ROI with cvSetImageROI(IplImage*,CvRect). After that you create your new image with the desired width and height. Finally you can copy your old image to the new one. The new image will contain your desired ROI.

Ramonn
  • 281
  • 2
  • 10
  • as are many images can not set a value for roi, they are not always in the same place, would have to calculate the concentration of pixels in the image. How to do this? Help me please? thank you – user2260178 Apr 10 '13 at 12:52
  • What kind of object(s) are you trying to detect? If they all share a common property you can use this to filter on that. Otherwise you will get a hard time defining all these objects – Ramonn Apr 10 '13 at 13:22
  • These are the kind of image I sent the link above. What changes is the displacement of digits that is horizontal. detecting the region of interest where the digits. What kind of filter that i apply? – user2260178 Apr 10 '13 at 19:49
  • You could use the example in the link above for thresholding the image. After that you should look at the findContours method. This function will detect the points you need and store them in a vector of points. Finally you can use the boundingRect method which will return a rectangle(square) with the points from findContours. If you then use cvSetImageROI you should have a dynamical region of interest! – Ramonn Apr 12 '13 at 07:49