Pre processing image before applying Canny Edge detection

Viewed 4058

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

1 Answers
Related