6
votes

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
The processing should be done in real time? Or you can spend (a few?) seconds?Miki
Try saturation or blue channel.Piglet
@Miki - It doesn't have to be done in real time, a few seconds are acceptable.WagglyWonga
@Piglet - I already tried increasing the saturation but it didn't change much, I'll try increasing the blue channel and see what the results are.WagglyWonga
@WagglyWonga what do you mean by increasing saturation and blue? You lose information when you create a gray image. Therefor try to do the edge detection in separate channels and combine the results. Can you get something else than Jpg? I took a look a that image and there are some pretty ugly compression artefacts in the hue channelPiglet

1 Answers

1
votes

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.