Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you have access to the <a href="https://www.mathworks.com/help/images/" rel="nofollow noreferrer">Image Processing Toolbox</a>, you can take advantage of a number of filtering and morphological operations it contains. Here's one way you could approach your problem, using the functions <a href="https://www.mathworks.com/help/images/ref/imfilter.html" rel="nofollow noreferrer"><code>imfilter</code></a>, <a href="https://www.mathworks.com/help/images/ref/imclose.html" rel="nofollow noreferrer"><code>imclose</code></a>, and <a href="https://www.mathworks.com/help/images/ref/imregionalmax.html" rel="nofollow noreferrer"><code>imregionalmax</code></a>:</p> <pre><code>% Load and plot the image data: imageData = imread('lattice_pic.jpg'); % Load the lattice image subplot(221); imshow(imageData); title('Original image'); % Gaussian-filter the image: gaussFilter = fspecial('gaussian', [31 31], 9); % Create the filter filteredData = imfilter(imageData, gaussFilter); subplot(222); imshow(filteredData); title('Gaussian-filtered image'); % Perform a morphological close operation: closeElement = strel('disk', 31); % Create a disk-shaped structuring element closedData = imclose(filteredData, closeElement); subplot(223); imshow(closedData); title('Closed image'); % Find the regions where local maxima occur: maxImage = imregionalmax(closedData); maxImage = imdilate(maxImage, strel('disk', 5)); % Dilate the points to see % them better on the plot subplot(224); imshow(maxImage); title('Maxima locations'); </code></pre> <p>And here's the image the above code creates:</p> <p><a href="https://i.stack.imgur.com/4JSRd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4JSRd.jpg" alt="enter image description here"></a></p> <p>To get things to look good I just kept trying a few different combinations for the parameters for the Gaussian filter (created using <a href="https://www.mathworks.com/help/images/ref/fspecial.html" rel="nofollow noreferrer"><code>fspecial</code></a>) and the structuring element (created using <a href="https://www.mathworks.com/help/images/ref/strel-class.html" rel="nofollow noreferrer"><code>strel</code></a>). However, that little bit of trial and error gave a very nice result.</p> <p><strong>NOTE:</strong> The image returned from <a href="https://www.mathworks.com/help/images/ref/imregionalmax.html" rel="nofollow noreferrer"><code>imregionalmax</code></a> doesn't always have just single pixels set to 1 (to indicate a maxima). The output image often contains clusters of pixels because neighboring pixels in the input image can have equal values, and are therefore both counted as maxima. In the code above I also dilated these points with <a href="https://www.mathworks.com/help/images/ref/imdilate.html" rel="nofollow noreferrer"><code>imdilate</code></a> just to make them easier to see in the image, which makes an even bigger cluster of pixels centered on the maxima. If you want to reduce the cluster of pixels to a single pixel, you should remove the dilation step and modify the image in other ways (add noise to the result or filter it, then find the new maxima, etc.).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload