6

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

Miki
  • 40,887
  • 13
  • 123
  • 202
WagglyWonga
  • 341
  • 3
  • 14
  • The processing should be done in real time? Or you can spend (a few?) seconds? – Miki Mar 10 '16 at 17:39
  • 1
    Try saturation or blue channel. – Piglet Mar 10 '16 at 20:45
  • @Miki - It doesn't have to be done in real time, a few seconds are acceptable. – WagglyWonga Mar 11 '16 at 09:07
  • @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 Mar 11 '16 at 09:10
  • @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 channel – Piglet Mar 11 '16 at 09:45
  • @Piglet Sorry I misunderstood what you meant. I applied the edge detection on just the blue channel and got much better results, but I'm still struggling to get the vertical edge coming from the ceiling to the worktop and I think it's related to the shadows in the room. I'll try to upload a picture with code later. – WagglyWonga Mar 11 '16 at 17:31

1 Answers1

1

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.

Settembrini
  • 1,366
  • 3
  • 20
  • 32
  • Have you actually tried something? If so, can you post your code and your results? Or this is just a guess? – Miki Mar 11 '16 at 13:26
  • I don't work with open CV, but will check it on Matlab later and give an update here. – Settembrini Mar 11 '16 at 14:44
  • Nice! I'm pretty curious ;D – Miki Mar 11 '16 at 14:55
  • @Settembrini Thanks, I've tried to play around with detecting and removing the shadows/reflections from the image but I'm no expert in this area so it's just been trial and error. I'll try your approach with the histogram equalisation and see if that works. – WagglyWonga Mar 11 '16 at 17:35
  • @Settembrini the transition from ceiling to wall in the problematic area is so smooth that a gradient based approach won't find an edge as the gradient is very low. How should histogram equalization help here? you cannot add information to an image. you can just alter it. histogram equalization is mainly to improve visibility for the human eye. it won't help here at all. if your image is bad now pre-processing in the world will change that. – Piglet Mar 11 '16 at 20:44
  • @piglet I agree the edge that settembrini looked at is possibly too faint to detect but the vertical edge from the worktop to the ceiling is detected in a different app and I assume they must be removing the shadow somehow to get a straight edge – WagglyWonga Mar 11 '16 at 23:13