1
$\begingroup$

I'm asking for the community help since I have problems in cropping an image. I'm having LEED images which are 576*720p, which are made by a big black region at which middle I have the image I'm analizing. Since the region is circular, i would like to single that out of the black region, but I haven't really found a way to do so. By now, if this is the image:

LEED diffraction pattern

I'm able, via the function "EdgeDetect", to put in evidence the circular region i would like to preserve of the full image:

What i get via EdgeDetect

The circular region is evident, even if it's a little smaller that what's in reality(that's because i thing mathematica takes the edges of variation, which by many means may be closer to the center of the image that in reality). Anyway, I haven't been able to find a function in mathematica (nor to write it, actually I don't how to implement) to get that circular region (and possibly some more) and have the rest of the image cropped out. That would really light my code, and I'm asking if anyone has any idea on how to solve it.

Thanks in advance for your help

$\endgroup$
4
  • $\begingroup$ Just curious... diffraction pattern in a reflecting telescope? (I used ImageAdjust to brighten the image...) $\endgroup$ Commented Apr 15, 2015 at 2:29
  • $\begingroup$ you send electrons by that central thing (an electronic gun). Those electrons are then scattered by the sample, and thanks to the periodicity of the surface you will get diffraction spots (in directions normal to the surface), only by electrons that are elastically scattered. The principle is the one of the van laue scattering. There's a nice wikipedia page about LEED: link. What you then have is a less than 2Pi solid angle fluorescent screen to get the image. $\endgroup$
    – Andrea
    Commented Apr 15, 2015 at 17:16
  • $\begingroup$ Try this: Colorize[ImageData[img, Automatic]]. You can see that there is only a one-value difference between the inside and outside of the circle, and that the edges are not sharp enough to reliably detect. If your camera is always mounted in the same place you can use David's cropping method, but otherwise you'll have to align the images manually. $\endgroup$ Commented Apr 15, 2015 at 17:40
  • $\begingroup$ unfortunately the sample is not always in the same position since it's moved... that's the main problem. $\endgroup$
    – Andrea
    Commented Apr 15, 2015 at 17:54

2 Answers 2

1
$\begingroup$

First I'll import your image:

img = Import["https://i.sstatic.net/JU26d.png"]

enter image description here

As I mentioned in my comment, the image is too dark to detect the central circle. There is only a one-bit difference between the inside and the outside, and amount of noise is too large.

Colorize[ImageData[img, Automatic]]

enter image description here

(In the future I'd suggest marking three points on the rim with colored LEDs, or taking a lights-on and light-off pair to make detection easier.)

We can, however, detect the diffraction spots fairly easily:

LocalAdaptiveBinarize[img, 32, {1, 0, 0.02}]

enter image description here

And from there we can compute the bounding circle:

circle = ComponentMeasurements[ImageData@LocalAdaptiveBinarize[img, 32, {1, 0, 0.02}],
   {"BoundingDiskCenter", "BoundingDiskRadius"}][[1, 2]]

And show it against the original image:

Show[ImageAdjust@img, Graphics[{Red, Circle @@ circle}]]

enter image description here

And finally we can extract the ROI like so:

ImageTrim[img, Through[{Plus, Subtract} @@ circle]]

enter image description here

You will probably have to tweak the values to get all your images to be reliably detected, but all these operations should be pretty fast (as long as you keep the second element of the list argument to LocalAdaptiveBinarize, the standard deviation weight, at zero.)

$\endgroup$
1
  • $\begingroup$ That's it! thanks a lot for your help. Apart from the tweaking, it works well $\endgroup$
    – Andrea
    Commented Apr 15, 2015 at 22:17
0
$\begingroup$

Click and drop your figure or name it myFig. Then

ImageTake[myFig, {120, 500}, {130, 530}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Yes, but how can i get it iterative? Furthermore I'd like the cropping to have always the same dimensions of the image to compare nicely intensity plots made by considering rows of pixels from different images. So that cropping doesn't affect "position" in pixels of the spots. I mean, maybe also finding the center of the profile of the central big spot (the gun) and taking a region starting from there (e.g. always a 200x200 square of pixels) would work. The problem is, I'm not into the feature detection thing.... Thanks for your help $\endgroup$
    – Andrea
    Commented Apr 15, 2015 at 17:21
  • $\begingroup$ @Andrea I don't quite understand what you mean by "iterative." "Iterative" means that you perform an operation (on an image), then perform it on the processed image, then perform it again on that processed image, etc. Do you instead mean "automatic," so that one simply applies the algorithm to an arbitrary source image? $\endgroup$ Commented Apr 15, 2015 at 17:38
  • $\begingroup$ whops, automatic, every time i plug a similar image it does the same work on it $\endgroup$
    – Andrea
    Commented Apr 15, 2015 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.