I have previously asked a question Marking an interest point in an image using c++. I used the same solution and got the required point using the adaptive threshold and Blob Detection Algorithm(Growing Regions). I have the original source figure where I want to detect the rectangular region at the center
Original Image:
.But after I used the algorithm, I got something like this(details are visible if you open it in a new tab)
Marked Image:
where apart from the rectangular region the bright day light illuminated spots are also visible. I have used bilateral filtering but still I am not able to detect the rectangular region.But this algorithm works for the Night image where the background is more darker as expected.
Can someone suggest me whether the same algorithm with some modifications is sufficient or any other efficient ways are available..
Thanks
Using a simple combination of blur & threshold I managed to get this result (resized for viewing purposes):
After that, applying erosion & the squares.cpp technique (which is a sample from OpenCV) outputs:
which is almost the result you are looking for: the bottom part of the rectangle was successfully detected. All you need to do is increase the height of the detected rectangle (red square) to fit your area of interest.
Code:
EDIT:
The
find_squares()function returns a vector with all the squares found in the image. Because it iterates on every channel of the image, on your example it successfully detects the rectangular region in each of them, so printingsquares.size()outputs3.As a square can be seen as a vector of 4 (X,Y) coordinates, OpenCV express this concept as
vector<Point>allowing you to access the X and Y part the coordinate.Now, printing
squaresrevelead that the points were detected in a counterclockwise direction:Following this example, its fairly obvious that if you need to increase the height of the rectangle you need to change the Y of the 1st and 4th points: