Using imtophat in MATLAB

2019-08-02 17:45发布

I'm trying to do top hat filtering in MATLAB. The imtophat function looks promising, but I have no idea how to use it. I don't have a lot of work with MATLAB before. I am trying to look find basically small spots several pixels wide that are local maxima in my 2 dimensional array.

3条回答
在下西门庆
2楼-- · 2019-08-02 18:09

The documentation on imtophat has an example .. did you try it? The following images are from the MATLAB documentation.

Code

I = imread('rice.png');
imshow(I)
se = strel('disk',12);
J = imtophat(I,se);
figure, imshow(J,[])

Original

input rice image

(image source: mathworks.com)

Top Hat with a disk structuring element

rice image with tophat filter applied, and contrast-stretched

(image source: mathworks.com)

查看更多
Rolldiameter
3楼-- · 2019-08-02 18:10

tophat is basically an "opening" procedure followed by a subtraction of the result from the original image. the best and most helpful explanation of opening I've found here:
http://homepages.inf.ed.ac.uk/rbf/HIPR2/morops.htm

"The effect of opening can be quite easily visualized. Imagine taking the structuring element and sliding it around inside each foreground region, without changing its orientation. All pixels which can be covered by the structuring element with the structuring element being entirely within the foreground region will be preserved. However, all foreground pixels which cannot be reached by the structuring element without parts of it moving out of the foreground region will be eroded away."

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-08-02 18:21

I think you have more problem undertanding how to use STREL, than IMTOPHAT. The later can be described as simple threshold but per structural element, not the whole image.

Here is another good examples of using STREL and IMTOPHAT: http://www.mathworks.com/matlabcentral/fx_files/2573/1/content/html/R14_MicroarrayImage_CaseStudy.html

This series of posts on Steve Eddins blog might be useful for you: http://blogs.mathworks.com/steve/category/dilation-algorithms/

查看更多
登录 后发表回答