Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pre processing image before applying Canny Edge detection

I have an image of a room below and I want to detect all wall edges. I've tried a lot of different combinations of filters (Bilateral, Gaussian, Laplacian, etc.) and the best combination seems to be the following,

  • Convert the image to grayscale
  • Apply a bilateral filter
  • Run the Canny edge detection process
  • Apply two more bilateral filters to remove any noise
  • Apply a dilation filter to 'plug' any holes in the edges

The problem I have is that no matter what I've tried I can never get a distinct straight edge that runs across the wall adjacent to the ceiling. I've tried a number of techniques to try to darken the edge but to no avail. There is an app on the app store that detects this edge so I know it can be done, I'm just not sure what pre processing filters I need to apply, hope somebody can point me in the right direction.

cv::Mat edgeFrame;
cv::Mat grayImage;
cv::Mat blurFrame;
outputFrame=inputFrame.clone();

getGray(inputImage, grayImage);
cv::bilateralFilter(grayImage, blurFrame, 9,80, 80);
cv:Canny(blurFrame, edgeImage,100, 110,5);
cv::bilateralFilter(edgeImage, blurFrame, 21 , 80, 80);
cv::bilateralFilter(blurFrame, edgeImage,21, 100, 150);
int dilation_size =1;
Mat element = getStructuringElement( MORPH_ELLIPSE,
                                    Size( 2*dilation_size + 1, 2*dilation_size+1 ),
                                    Point( dilation_size, dilation_size ) );
dilate( edgeImage, outputFrame, element );

enter image description here

enter image description here

like image 298
WagglyWonga Avatar asked Mar 10 '16 16:03

WagglyWonga


1 Answers

The problem are the shadows in those edges, caused by the fact that illumination comes entirely from the sun through the window and there is no light source inside the room. Also the picture is relatively dark, so that its histogram will be concentrated on the lower side. Having said this, I would apply histogram equalisation as a first step to spread intensity over the whole range 0-255 and then, within canny apply a relatively large sigma (gauss blur) in order to suppress the high frequency edges.

Update: 1) greyvalue enter image description here

2) histeq enter image description here

3) canny enter image description here

Indeed, while histeq increases contrast, it cannot help here, since in that region above the door the gradients are virtually zero, as you can see well from the second picture.

like image 170
Settembrini Avatar answered Oct 04 '22 12:10

Settembrini