Group Abstract Group Abstract

Message Boards Message Boards

0
|
7K Views
|
7 Replies
|
9 Total Likes
View groups...
Share
Share this post:

Edge detection of a noisy rim

Posted 11 years ago
Attachments:
POSTED BY: qiang li
7 Replies

This problem is so interesting that I try a "solution" as well.

Let "img" be the original image. Then the trick can be done by:

imgLens = 
 Thinning@Binarize@
   DeleteBorderComponents@
    SelectComponents[Blur@EdgeDetect[img, 4], 
     "EnclosingComponentCount", # == 0 &]

which gives: enter image description here

I am not really satisfied with this method, because it depends quite sensitive on the parameter of EdgeDetect.

From this one can easily extract the coordinates of the boundary of the lens:

imgDims = ImageDimensions[imgLens];
pts = {#2, imgDims[[1]] - #1 + 1} & @@@ 
   Position[ImageData@imgLens, 1, {2}];

Graphics[{Blue, PointSize[.004], Point[pts]}, Axes -> True, 
 Frame -> True]

enter image description here

Ciao Henrik

POSTED BY: Henrik Schachner

Yes, first comes the edge detection (which is quite sensible), then I blur a little (an attempt to have a closed contour), then I can apply

SelectComponents[ ... ,"EnclosingComponentCount", # == 0 &]

which actually does the work by selecting the outermost closed contour. (If this contour is not closed one gets the next closed one, the result then is the picture in Marco's last post.) The original picture has a very sharp edge on its left side, therefore DeleteBorderComponents is necessary. Finally Binarize to get {0 or 1} and Thinning to make the contourline "slim".

Ciao Henrik

POSTED BY: Henrik Schachner

Hi,

this is far from being efficient, it uses too many image processing commands and could hardly be less elegant. But it does find the edge - more or less.

ImageMultiply[img, 
 ColorNegate@
  EdgeDetect[
   WatershedComponents@
     Binarize@
      ImageMultiply[img, 
       Sharpen[Erosion[
          Dilation[
           MeanFilter[
            SelectComponents[
              SelectComponents[
               SelectComponents[(MorphologicalComponents[
                  BottomHatTransform[
                   GradientFilter[
                    DeleteSmallComponents@(MorphologicalComponents[
                    img, 0.562] // Colorize), 1.64], DiskMatrix[6]], 
                  Method -> "Connected"]), Large], "Count", -3], 
              "Count", 1] // Colorize, 6], 6], 7] // ImageAdjust, 
        10]] // Colorize]]

I called the image just img. Here's the result:

enter image description here

Cheers,

Marco

POSTED BY: Marco Thiel

Dear Marco,

it is nice that you like my "solution", I basically don't do anything - it is more a demonstration of the ability of Mathematica. And still the original problem is not solved: To recognice the border of lenses in a whole series of similar but different pictures. A slight variation - as you just found out (a really strange effect!) - ruins everything. I think an enhancement of the contrast (e.g. with ImageAdjust[img, 2]) might help a little.

Ciao Henrik

POSTED BY: Henrik Schachner

Dear Henrik,

that looks like a really great solution, much better than mine. I tried it out and got a different result when I use your command:

enter image description here

This was because I imported the file by "pulling it from the post". If I get it into Mathematica using Import I get what you report. That is curious because in both cases the image has the same resolution, i.e. ImageDimensions gives the same, namely {1311, 976}. Also the different result does not seem to depend on the parameter of EdgeDetect.

Anyway, your solution is much nicer than mine.

Cheers,

Marco

POSTED BY: Marco Thiel
Posted 11 years ago

Wow. That is really neat result. So the processing includes? 1. Edge detect 2. blur
3. DeleteBorderComponents? 4. Binarize 5. Thinning

POSTED BY: qiang li
Posted 11 years ago
POSTED BY: qiang li
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard